summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/declarative/qtbinding.qdoc19
-rw-r--r--doc/src/snippets/declarative/qtbinding/enums/standalone.qml15
-rw-r--r--src/declarative/qml/qdeclarativeboundsignal.cpp28
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp3
-rw-r--r--src/gui/kernel/qwidget_mac.mm2
-rw-r--r--src/gui/text/qfragmentmap_p.h5
-rw-r--r--src/gui/text/qtextobject.cpp5
-rw-r--r--src/gui/text/qtextobject.h2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml8
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp46
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp42
-rw-r--r--tests/auto/qtextblock/tst_qtextblock.cpp12
15 files changed, 160 insertions, 33 deletions
diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc
index d11825e..3659caa 100644
--- a/doc/src/declarative/qtbinding.qdoc
+++ b/doc/src/declarative/qtbinding.qdoc
@@ -368,6 +368,10 @@ instead to create the signal handler:
\o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml 0
\endtable
+C++ signals can use enum values as parameters provided that the enum is declared in the
+class that is emitting the signal, and that the enum is registered using Q_ENUMS.
+See \l {Using enumerations of a custom type} below for details.
+
\section2 Modifying properties
@@ -503,6 +507,21 @@ the \l {Extending QML Functionalities using C++} reference documentation for
more information.
+\section2 Using enumeration values as signal parameters
+
+C++ signals may pass enumeration values as signal parameters to QML, providing that the enumeration
+and the signal are declared within the same class, or that the enumeration value is one of those declared
+in the \l {Qt}{Qt Namespace}.
+
+Additionally, if a C++ signal with an enum parameter should be connectable to a QML function using the
+\l {Connecting signals to methods and other signals}{connect()} function, the enum type must be
+registered using qRegisterMetaType().
+
+For QML signals, enum values may be used as signal parameters using the \c int type:
+
+\snippet doc/src/snippets/declarative/qtbinding/enums/standalone.qml 1
+
+
\section2 Automatic type conversion from strings
As a convenience, some basic types can be specified in QML using format strings to make it easier to
diff --git a/doc/src/snippets/declarative/qtbinding/enums/standalone.qml b/doc/src/snippets/declarative/qtbinding/enums/standalone.qml
index 5721870..74e2c9c 100644
--- a/doc/src/snippets/declarative/qtbinding/enums/standalone.qml
+++ b/doc/src/snippets/declarative/qtbinding/enums/standalone.qml
@@ -38,6 +38,9 @@
**
****************************************************************************/
import MyLibrary 1.0
+import QtQuick 1.0
+
+Item {
//![0]
ImageViewer {
@@ -47,3 +50,15 @@ ImageViewer {
}
}
//![0]
+
+//![1]
+ImageViewer {
+ signal someOtherSignal(int statusValue)
+
+ Component.onCompleted: {
+ someOtherSignal(ImageViewer.Loading)
+ }
+}
+//![1]
+
+}
diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp
index 28dfea9..47a15cb 100644
--- a/src/declarative/qml/qdeclarativeboundsignal.cpp
+++ b/src/declarative/qml/qdeclarativeboundsignal.cpp
@@ -225,9 +225,35 @@ QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(const QMeta
QMetaPropertyBuilder prop = mob.addProperty(name, "QObject*");
prop.setWritable(false);
} else {
+ QByteArray propType = type;
+ if (t >= QVariant::UserType || t == QVariant::Invalid) {
+ //copy of QDeclarativeObjectScriptClass::enumType()
+ QByteArray scope;
+ QByteArray name;
+ int scopeIdx = propType.lastIndexOf("::");
+ if (scopeIdx != -1) {
+ scope = propType.left(scopeIdx);
+ name = propType.mid(scopeIdx + 2);
+ } else {
+ name = propType;
+ }
+ const QMetaObject *meta;
+ if (scope == "Qt")
+ meta = &QObject::staticQtMetaObject;
+ else
+ meta = parent->parent()->metaObject(); //### assumes parent->parent()
+ for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
+ QMetaEnum m = meta->enumerator(i);
+ if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope))) {
+ t = QVariant::Int;
+ propType = "int";
+ break;
+ }
+ }
+ }
if (QDeclarativeMetaType::canCopy(t)) {
types[ii] = t;
- QMetaPropertyBuilder prop = mob.addProperty(name, type);
+ QMetaPropertyBuilder prop = mob.addProperty(name, propType);
prop.setWritable(false);
} else {
types[ii] = 0x80000000 | t;
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index fb77ec3..61b2d34 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -1301,9 +1301,6 @@ int NestedListModel::count() const
void NestedListModel::clear()
{
- _rolesOk = false;
- roleStrings.clear();
-
if (_root)
_root->clear();
}
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index f5a9e27..354f05b 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -2885,7 +2885,7 @@ void QWidgetPrivate::setSubWindowStacking(bool set)
if ([pwin isVisible]
&& (ptype == Qt::Window || ptype == Qt::Dialog)
&& ![qwin parentWindow]
- && (!use_behaviour_qt473 && parent->windowModality() == Qt::ApplicationModal)) {
+ && (use_behaviour_qt473 || parent->windowModality() == Qt::ApplicationModal)) {
NSInteger level = [qwin level];
[pwin addChildWindow:qwin ordered:NSWindowAbove];
if ([qwin level] < level)
diff --git a/src/gui/text/qfragmentmap_p.h b/src/gui/text/qfragmentmap_p.h
index 501bfff..4057142 100644
--- a/src/gui/text/qfragmentmap_p.h
+++ b/src/gui/text/qfragmentmap_p.h
@@ -195,6 +195,10 @@ public:
head->root = new_root;
}
+ inline bool isValid(uint n) const {
+ return n > 0 && n != head->freelist;
+ }
+
union {
Header *head;
Fragment *fragments;
@@ -854,6 +858,7 @@ public:
return data.fragment(index);
}
inline uint position(uint node, uint field = 0) const { return data.position(node, field); }
+ inline bool isValid(uint n) const { return data.isValid(n); }
inline uint next(uint n) const { return data.next(n); }
inline uint previous(uint n) const { return data.previous(n); }
inline uint size(uint node, uint field = 0) const { return data.size(node, field); }
diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp
index 0081550..9139561 100644
--- a/src/gui/text/qtextobject.cpp
+++ b/src/gui/text/qtextobject.cpp
@@ -891,6 +891,11 @@ QTextBlockUserData::~QTextBlockUserData()
Returns true if this text block is valid; otherwise returns false.
*/
+bool QTextBlock::isValid() const
+{
+ return p != 0 && p->blockMap().isValid(n);
+}
+
/*!
\fn QTextBlock &QTextBlock::operator=(const QTextBlock &other)
diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h
index fface3f..7c3cefa 100644
--- a/src/gui/text/qtextobject.h
+++ b/src/gui/text/qtextobject.h
@@ -205,7 +205,7 @@ public:
inline QTextBlock(const QTextBlock &o) : p(o.p), n(o.n) {}
inline QTextBlock &operator=(const QTextBlock &o) { p = o.p; n = o.n; return *this; }
- inline bool isValid() const { return p != 0 && n != 0; }
+ bool isValid() const;
inline bool operator==(const QTextBlock &o) const { return p == o.p && n == o.n; }
inline bool operator!=(const QTextBlock &o) const { return p != o.p || n != o.n; }
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
index 8addcb9..6467c42 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
@@ -1,5 +1,5 @@
import Qt.test 1.0
MyQmlObject {
- onArgumentSignal: setString('pass ' + a + ' ' + b + ' ' + c)
+ onArgumentSignal: setString('pass ' + a + ' ' + b + ' ' + c + ' ' + d + ' ' + e)
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
index ffbe317..4fc2dab 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
@@ -7,10 +7,12 @@ MyQmlObject
property real realProperty
property color colorProperty
property variant variantProperty
+ property int enumProperty
+ property int qtEnumProperty
- signal mySignal(int a, real b, color c, variant d)
+ signal mySignal(int a, real b, color c, variant d, int e, int f)
- onMySignal: { intProperty = a; realProperty = b; colorProperty = c; variantProperty = d; }
+ onMySignal: { intProperty = a; realProperty = b; colorProperty = c; variantProperty = d; enumProperty = e; qtEnumProperty = f; }
- onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1))
+ onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1), MyQmlObject.EnumValue3, Qt.LeftButton)
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
index 7e63bd5..1d65b15 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
@@ -127,6 +127,8 @@ void registerTypes()
qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit");
qRegisterMetaType<MyQmlObject::MyType>("MyQmlObject::MyType");
+ qRegisterMetaType<MyQmlObject::MyType>("MyEnum2");
+ qRegisterMetaType<Qt::MouseButtons>("Qt::MouseButtons");
}
#include "testtypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
index 081cc4c..94cec3f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -159,7 +159,7 @@ public:
signals:
void basicSignal();
- void argumentSignal(int a, QString b, qreal c);
+ void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e);
void stringChanged();
void objectChanged();
void anotherBasicSignal();
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 48466d5..7876671 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -304,8 +304,8 @@ void tst_qdeclarativeecmascript::signalAssignment()
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->string(), QString());
- emit object->argumentSignal(19, "Hello world!", 10.25);
- QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25"));
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2"));
}
}
@@ -870,7 +870,7 @@ void tst_qdeclarativeecmascript::scope()
QCOMPARE(object->property("test").toInt(), 0);
QCOMPARE(object->property("test2").toString(), QString());
- emit object->argumentSignal(13, "Argument Scope", 9);
+ emit object->argumentSignal(13, "Argument Scope", 9, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 13);
QCOMPARE(object->property("test2").toString(), QString("Argument Scope"));
@@ -895,6 +895,8 @@ void tst_qdeclarativeecmascript::signalParameterTypes()
QCOMPARE(object->property("realProperty").toReal(), 19.2);
QVERIFY(object->property("colorProperty").value<QColor>() == QColor(255, 255, 0, 255));
QVERIFY(object->property("variantProperty") == QVariant::fromValue(QColor(255, 0, 255, 255)));
+ QVERIFY(object->property("enumProperty") == MyQmlObject::EnumValue3);
+ QVERIFY(object->property("qtEnumProperty") == Qt::LeftButton);
}
/*
@@ -1139,7 +1141,7 @@ void tst_qdeclarativeecmascript::signalTriggeredBindings()
QCOMPARE(object->property("test1").toReal(), 200.);
QCOMPARE(object->property("test2").toReal(), 200.);
- object->argumentSignal(10, QString(), 10);
+ object->argumentSignal(10, QString(), 10, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("base").toReal(), 400.);
QCOMPARE(object->property("test1").toReal(), 400.);
@@ -1940,7 +1942,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toBool(), true);
delete object;
@@ -1953,7 +1955,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toBool(), true);
delete object;
@@ -1966,7 +1968,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toBool(), true);
delete object;
@@ -1979,7 +1981,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->methodCalled(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->methodCalled(), true);
delete object;
@@ -1992,7 +1994,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->methodCalled(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->methodCalled(), true);
delete object;
@@ -2005,7 +2007,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
delete object;
@@ -2021,13 +2023,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
delete object;
@@ -2040,13 +2042,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
delete object;
@@ -2059,13 +2061,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 3);
delete object;
@@ -2077,13 +2079,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 3);
delete object;
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
index 45072f3..2f7513f 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
@@ -106,6 +106,7 @@ private slots:
void property_changes_data();
void property_changes_worker();
void property_changes_worker_data();
+ void clear();
};
int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model, const QString &roleName)
{
@@ -1091,6 +1092,47 @@ void tst_qdeclarativelistmodel::property_changes_worker_data()
property_changes_data();
}
+void tst_qdeclarativelistmodel::clear()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeListModel model;
+ QDeclarativeEngine::setContextForObject(&model, engine.rootContext());
+ engine.rootContext()->setContextObject(&model);
+
+ QScriptEngine *seng = QDeclarativeEnginePrivate::getScriptEngine(&engine);
+ QScriptValue sv = seng->newObject();
+ QVariant result;
+
+ model.clear();
+ QCOMPARE(model.count(), 0);
+
+ sv.setProperty("propertyA", "value a");
+ sv.setProperty("propertyB", "value b");
+ model.append(sv);
+ QCOMPARE(model.count(), 1);
+
+ model.clear();
+ QCOMPARE(model.count(), 0);
+
+ model.append(sv);
+ model.append(sv);
+ QCOMPARE(model.count(), 2);
+
+ model.clear();
+ QCOMPARE(model.count(), 0);
+
+ // clearing does not remove the roles
+ sv.setProperty("propertyC", "value c");
+ model.append(sv);
+ QList<int> roles = model.roles();
+ model.clear();
+ QCOMPARE(model.count(), 0);
+ QCOMPARE(model.roles(), roles);
+ QCOMPARE(model.toString(roles[0]), QString("propertyA"));
+ QCOMPARE(model.toString(roles[1]), QString("propertyB"));
+ QCOMPARE(model.toString(roles[2]), QString("propertyC"));
+}
+
QTEST_MAIN(tst_qdeclarativelistmodel)
#include "tst_qdeclarativelistmodel.moc"
diff --git a/tests/auto/qtextblock/tst_qtextblock.cpp b/tests/auto/qtextblock/tst_qtextblock.cpp
index cec3a6a..748d921 100644
--- a/tests/auto/qtextblock/tst_qtextblock.cpp
+++ b/tests/auto/qtextblock/tst_qtextblock.cpp
@@ -76,6 +76,7 @@ private slots:
void excludeParagraphSeparatorFragment();
void backwardsBlockIterator();
void previousBlock_qtbug18026();
+ void removedBlock_qtbug18500();
private:
QTextDocument *doc;
@@ -181,5 +182,16 @@ void tst_QTextBlock::previousBlock_qtbug18026()
QVERIFY(last.isValid());
}
+void tst_QTextBlock::removedBlock_qtbug18500()
+{
+ cursor.insertText("line 1\nline 2\nline 3 \nline 4\n");
+ cursor.setPosition(7);
+ QTextBlock block = cursor.block();
+ cursor.setPosition(21, QTextCursor::KeepAnchor);
+
+ cursor.removeSelectedText();
+ QVERIFY(!block.isValid());
+}
+
QTEST_MAIN(tst_QTextBlock)
#include "tst_qtextblock.moc"