diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-11-25 09:52:02 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-25 12:40:42 +0100 |
commit | 2f87fde9bb4bad6787101c0d135419b350b201a5 (patch) | |
tree | 6831d165dd7facb9aae2a692450d2f6866398392 /src/corelib/kernel | |
parent | eafa224c3bfff86839581536d832cbaf8045a264 (diff) |
Allow for QtDeclarative and QtQml to co-exist at run-time
Qml has a bunch of hooks in QObject, that are callbacks as function pointers
when things happen in QObject. QtDeclarative (Qml1) only needs one callback,
for object destruction. In preparation for allowing both run-times to co-exist,
this patch forks the callback, keeping the "default" variant for QtQml and
having a *_qml1 variant for QtDeclarative. QtQml continues to set the callback
variable for the default and QtDeclarative will set the _qml1 variant.
It is however a limitation that a QObject instance can only be exposed to _one_
engine at a time, and it is not possible to make a transfer. Double exposure
will result in crashes.
This patch alone is not sufficient to fix the bug, the
QQmlData/QDeclarativeData structures in Qml1 and Qml2 need to be extended to
allow distinction at run-time.
Task-number: QTBUG-35006
Change-Id: I3bac023873b5656a8a4f117fe816bafcda77b67d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 11 | ||||
-rw-r--r-- | src/corelib/kernel/qobject_p.h | 1 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 282672ddc7..6ed3b30917 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -177,6 +177,7 @@ private: void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject *) = 0; +void (*QAbstractDeclarativeData::destroyed_qml1)(QAbstractDeclarativeData *, QObject *) = 0; void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = 0; void (*QAbstractDeclarativeData::signalEmitted)(QAbstractDeclarativeData *, QObject *, int, void **) = 0; int (*QAbstractDeclarativeData::receivers)(QAbstractDeclarativeData *, const QObject *, int) = 0; @@ -805,8 +806,12 @@ QObject::~QObject() } } - if (d->declarativeData) - QAbstractDeclarativeData::destroyed(d->declarativeData, this); + if (d->declarativeData) { + if (QAbstractDeclarativeData::destroyed) + QAbstractDeclarativeData::destroyed(d->declarativeData, this); + if (QAbstractDeclarativeData::destroyed_qml1) + QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this); + } // set ref to zero to indicate that this object has been deleted if (d->currentSender != 0) @@ -1859,7 +1864,7 @@ void QObjectPrivate::setParent_helper(QObject *o) } } } - if (!isDeletingChildren && declarativeData) + if (!isDeletingChildren && declarativeData && QAbstractDeclarativeData::parentChanged) QAbstractDeclarativeData::parentChanged(declarativeData, q, o); } diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index f5745515c9..cd2d592cec 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -90,6 +90,7 @@ class Q_CORE_EXPORT QAbstractDeclarativeData { public: static void (*destroyed)(QAbstractDeclarativeData *, QObject *); + static void (*destroyed_qml1)(QAbstractDeclarativeData *, QObject *); static void (*parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *); static void (*signalEmitted)(QAbstractDeclarativeData *, QObject *, int, void **); static int (*receivers)(QAbstractDeclarativeData *, const QObject *, int); |