From 9c515a6de24bc8d5709136cc099ceeae8e3e642c Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 25 Jul 2017 13:14:21 +0200 Subject: Do not (dis)connectNotify on dynamically created model item objects These item objects are direct subclasses of QObject, and cannot override connectNotify/disconnectNotify. This prevents the creation of the backing QMetaObject during disconnect, which happens during destruction, which in turn will call back into the model that is being destroyed. Task-number: QTBUG-59704 Change-Id: I7f997e5d2fda242b38e67b9147224d72aa4508ba Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlnotifier_p.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/qml/qml/qqmlnotifier_p.h') diff --git a/src/qml/qml/qqmlnotifier_p.h b/src/qml/qml/qqmlnotifier_p.h index dad79e0e55..6e91369793 100644 --- a/src/qml/qml/qqmlnotifier_p.h +++ b/src/qml/qml/qqmlnotifier_p.h @@ -100,7 +100,7 @@ public: inline bool isConnected(QObject *source, int sourceSignal) const; inline bool isConnected(QQmlNotifier *) const; - void connect(QObject *source, int sourceSignal, QQmlEngine *engine); + void connect(QObject *source, int sourceSignal, QQmlEngine *engine, bool doNotify = true); inline void connect(QQmlNotifier *); inline void disconnect(); @@ -121,9 +121,10 @@ private: inline QQmlNotifier *senderAsNotifier() const; Callback callback:4; + int needsConnectNotify:1; // The index is in the range returned by QObjectPrivate::signalIndex(). // This is different from QMetaMethod::methodIndex(). - signed int sourceSignal:28; + signed int sourceSignal:27; }; QQmlNotifier::QQmlNotifier() @@ -155,7 +156,7 @@ void QQmlNotifier::notify() } QQmlNotifierEndpoint::QQmlNotifierEndpoint(Callback callback) -: next(0), prev(0), senderPtr(0), callback(callback), sourceSignal(-1) +: next(0), prev(0), senderPtr(0), callback(callback), needsConnectNotify(false), sourceSignal(-1) { } @@ -205,7 +206,8 @@ void QQmlNotifierEndpoint::disconnect() if (sourceSignal != -1) { QObject * const obj = senderAsObject(); QObjectPrivate * const priv = QObjectPrivate::get(obj); - priv->disconnectNotify(QMetaObjectPrivate::signal(obj->metaObject(), sourceSignal)); + if (needsConnectNotify) + priv->disconnectNotify(QMetaObjectPrivate::signal(obj->metaObject(), sourceSignal)); } if (isNotifying()) *((qintptr *)(senderPtr & ~0x1)) = 0; -- cgit v1.2.3