QQmlPropertyPrivate::signalExpression: handle object being null
QQmlData::get expects a non-null pointer, therefore we need to check whether the object still exists. Note that while this fixes the crash in the referenced bug, PropertyChanges still does not support a dynamic target. Pick-to: 5.12 5.15 6.0 6.1 Task-number: QTBUG-46350 Change-Id: Ifeecf5df83e87468a1d314ce2b120006124d6f4b Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
parent
3670395af5
commit
1ff376e64b
|
@ -922,6 +922,8 @@ QQmlPropertyPrivate::signalExpression(const QQmlProperty &that)
|
||||||
if (!(that.type() & QQmlProperty::SignalProperty))
|
if (!(that.type() & QQmlProperty::SignalProperty))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
if (!that.d->object)
|
||||||
|
return nullptr;
|
||||||
QQmlData *data = QQmlData::get(that.d->object);
|
QQmlData *data = QQmlData::get(that.d->object);
|
||||||
if (!data)
|
if (!data)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -961,6 +963,8 @@ void QQmlPropertyPrivate::takeSignalExpression(const QQmlProperty &that,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!that.d->object)
|
||||||
|
return;
|
||||||
QQmlData *data = QQmlData::get(that.d->object, nullptr != expr);
|
QQmlData *data = QQmlData::get(that.d->object, nullptr != expr);
|
||||||
if (!data)
|
if (!data)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -195,6 +195,8 @@ private slots:
|
||||||
void nestedQQmlPropertyMap();
|
void nestedQQmlPropertyMap();
|
||||||
|
|
||||||
void underscorePropertyChangeHandler();
|
void underscorePropertyChangeHandler();
|
||||||
|
|
||||||
|
void signalExpressionWithoutObject();
|
||||||
private:
|
private:
|
||||||
QQmlEngine engine;
|
QQmlEngine engine;
|
||||||
};
|
};
|
||||||
|
@ -2263,6 +2265,14 @@ void tst_qqmlproperty::underscorePropertyChangeHandler()
|
||||||
QVERIFY(changeHandler.isSignalProperty());
|
QVERIFY(changeHandler.isSignalProperty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_qqmlproperty::signalExpressionWithoutObject()
|
||||||
|
{
|
||||||
|
QQmlProperty invalid;
|
||||||
|
QQmlPropertyPrivate::setSignalExpression(invalid, nullptr);
|
||||||
|
QQmlBoundSignalExpression *expr = QQmlPropertyPrivate::signalExpression(invalid);
|
||||||
|
QVERIFY(!expr);
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_qqmlproperty)
|
QTEST_MAIN(tst_qqmlproperty)
|
||||||
|
|
||||||
#include "tst_qqmlproperty.moc"
|
#include "tst_qqmlproperty.moc"
|
||||||
|
|
Loading…
Reference in New Issue