[Development] Object destruction in QML 2

Thiago Lacerda thiago.lacerda at openbossa.org
Mon Jan 23 16:15:37 CET 2012


Hi

I've done a patch for https://bugreports.qt.nokia.com/browse/QTBUG-23451 and
I've faced an interesting problem.
The bug says that the changed signal is not raised when an Item property is
pointing to a dynamic object and this object gets destructed (changing the
value of the Item property to null).
My first patch works perfectly on QtQuick 1.1 (
https://qt.gitorious.org/~thiagolacerda/qt/thiagolacerdas-qt/commit/89ee5315e3739d36cd2b9feb958a6f48df0130da
),
but when I test it with QtQuick 2.0 the Item property assumes a
intermediate value, instead of changing directly to null it first gets
"undefined" value and then changes to null.

Then, by investigating the code, I've seen that
in src/declarative/qml/v8/qv8qobjectwrapper.cpp, at v8::Handle<v8::Value>
QV8QObjectWrapper::newQObject(QObject *object) method, this condition
exists:

if (QObjectPrivate::get(object)->wasDeleted)
       return v8::Undefined();

This is causing the "undefined" value of the property when the value of the
property is retrieved between the destroy function call and the real
destruction of the object.
I think this can cause some strange behaviors on the applications developed
using QtQuick. Why don't just return the null value, since we know that
this object was destructed and won't be available to the user anymore?

For that, I've updated my patch and submitted to gerrit as a Qt5 issue
correction (http://codereview.qt-project.org/#change,13986)

Cheers

-- 
Thiago de Barros Lacerda
OpenBossa - INdT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120123/bb938bf1/attachment.html>


More information about the Development mailing list