Skip to content

Commit

Permalink
Don't crash: Connections with a signal on a nonexistent object
Browse files Browse the repository at this point in the history
Task-number: QTBUG-56551
Change-Id: Ide09f177d3f6a3e9902f8ea904b3e6e4b998bd39
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
(cherry picked from commit 02830aa)
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
  • Loading branch information
ec1oud authored and tronical committed Aug 31, 2017
1 parent f724b53 commit 59b726e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/qml/qml/qqmlpropertycache.cpp
Expand Up @@ -1067,8 +1067,11 @@ int QQmlPropertyCache::originalClone(QObject *object, int index)
QQmlData *data = QQmlData::get(object, false);
if (data && data->propertyCache) {
QQmlPropertyCache *cache = data->propertyCache;
while (cache->signal(index)->isCloned())
QQmlPropertyData *sig = cache->signal(index);
while (sig && sig->isCloned()) {
--index;
sig = cache->signal(index);
}
} else {
while (QMetaObjectPrivate::signal(object->metaObject(), index).attributes() & QMetaMethod::Cloned)
--index;
Expand Down
@@ -0,0 +1,11 @@
import QtQuick 2.4

Item {
function hint() {
}

Connections {
target: BlaBlaBla
onHint: hint();
}
}
10 changes: 10 additions & 0 deletions tests/auto/quick/qquickitem2/tst_qquickitem.cpp
Expand Up @@ -101,6 +101,7 @@ private slots:
void mapCoordinatesRect();
void mapCoordinatesRect_data();
void propertyChanges();
void nonexistentPropertyConnection();
void transforms();
void transforms_data();
void childrenRect();
Expand Down Expand Up @@ -2588,6 +2589,15 @@ void tst_QQuickItem::propertyChanges()
delete window;
}

void tst_QQuickItem::nonexistentPropertyConnection()
{
// QTBUG-56551: don't crash
QQmlComponent component(&engine, testFileUrl("nonexistentPropertyConnection.qml"));
QObject *o = component.create();
QVERIFY(o);
delete o;
}

void tst_QQuickItem::childrenRect()
{
QQuickView *window = new QQuickView(0);
Expand Down

0 comments on commit 59b726e

Please sign in to comment.