diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-03-23 15:44:40 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-03-23 15:22:38 +0000 |
commit | 861f53d60cc2dd8bd8529c65863af881dbdd8db8 (patch) | |
tree | 26d916f161244447bc316a8410de78da1876728a /src/qmlmodels | |
parent | d7e847ba2553c2e937f844cd599bf7bc9e266563 (diff) |
PropertyUpdater: Do not crash on invalid context
If the context is gone, we assume that the object is
currently torn down. Therefore we do not print an error
message in that case.
Fixes: QTBUG-82809
Change-Id: I74e5a4f41490ea9c13639c158a4d5fc0a52a38a4
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qmlmodels')
-rw-r--r-- | src/qmlmodels/qqmldelegatemodel.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp index 02564a113a..12678696cc 100644 --- a/src/qmlmodels/qqmldelegatemodel.cpp +++ b/src/qmlmodels/qqmldelegatemodel.cpp @@ -946,15 +946,18 @@ void PropertyUpdater::breakBinding() return; if (updateCount == 0) { QObject::disconnect(*it); + senderToConnection.erase(it); QQmlError warning; - warning.setUrl(qmlContext(QObject::sender())->baseUrl()); + if (auto context = qmlContext(QObject::sender())) + warning.setUrl(context->baseUrl()); + else + return; auto signalName = QString::fromLatin1(QObject::sender()->metaObject()->method(QObject::senderSignalIndex()).name()); signalName.chop(sizeof("changed")-1); QString propName = signalName; propName[0] = propName[0].toLower(); warning.setDescription(QString::fromUtf8("Writing to \"%1\" broke the binding to the underlying model").arg(propName)); qmlWarning(this, warning); - senderToConnection.erase(it); } else { --updateCount; } |