<feed xmlns='http://www.w3.org/2005/Atom'>
<title>qt/qtdeclarative.git/src/qmlmodels/qqmladaptormodel.cpp, branch wip/iosstyle</title>
<subtitle>Qt Declarative (Quick 2)
</subtitle>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/'/>
<entry>
<title>Cleanup QQmlGuard and related classes</title>
<updated>2022-02-21T17:20:56+00:00</updated>
<author>
<name>Fabian Kosmale</name>
<email>fabian.kosmale@qt.io</email>
</author>
<published>2022-02-14T20:28:51+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=214b92b00a2f9c1527401a1a20bfcc2b30e8efab'/>
<id>214b92b00a2f9c1527401a1a20bfcc2b30e8efab</id>
<content type='text'>
An investigation of uses of QQmlGuard (+ related classes) yielded the
following results:

- objectDestroyed is the only virtual method of QQmlGuard (besides the
  dtor)
- we never have an owning pointer of type QQmlGuard * to one of its
  subclasess
=&gt; Therefore, we can replace the use of virtual methods with a function
pointer, which avoids the issue of duplicated vtables.

None of the objectDestroyed actually cares about the object we pass to
them, so we can leave it out in the function pointer. As everything is
private API, we could easily bring it back if the need arises in the
future.
By moving the function pointer into QQmlGuardImpl we also avoid UB in
qqmlengine.cpp, which cast any QQmlGuardImpl pointer to
QQmlGuard&lt;QObject&gt;. This, however, is wrong as QQmlGuard&lt;T&gt; does not
inherit from QQmlGuard&lt;QObject&gt;, even if T inherits from QObject. As we
now can sipmly access the pointer from QQmlGuardImpl, we can side-step
any casting woes alltogether.

Moreover, we use this opportunity to let QQmlStrongJSObjectReference
drectly inherit from QQmlGuardImpl. This requires duplicating some of
the QQmlGuard API, but on the other hand avoids busy-work to hide no
longer desired API.

Unfortunately, we can no longer inherit privately from QQmlGuardImpl, as
otherwise the various subclasses can no longer cast the QQmlGuardImpl we
pass to them to their own type in the objectDestroyed(Impl) methods.

QQmlGuard(Impl) still could benefit from a move ctor/assignment
operator; those will be added in a later commit.

Task-number: QTBUG-45582
Change-Id: I995148a428e541ced5c79b3a61d91c4bb7e03308
Reviewed-by: Marc Mutz &lt;marc.mutz@qt.io&gt;
Reviewed-by: Qt CI Bot &lt;qt_ci_bot@qt-project.org&gt;
Reviewed-by: Ulf Hermann &lt;ulf.hermann@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
An investigation of uses of QQmlGuard (+ related classes) yielded the
following results:

- objectDestroyed is the only virtual method of QQmlGuard (besides the
  dtor)
- we never have an owning pointer of type QQmlGuard * to one of its
  subclasess
=&gt; Therefore, we can replace the use of virtual methods with a function
pointer, which avoids the issue of duplicated vtables.

None of the objectDestroyed actually cares about the object we pass to
them, so we can leave it out in the function pointer. As everything is
private API, we could easily bring it back if the need arises in the
future.
By moving the function pointer into QQmlGuardImpl we also avoid UB in
qqmlengine.cpp, which cast any QQmlGuardImpl pointer to
QQmlGuard&lt;QObject&gt;. This, however, is wrong as QQmlGuard&lt;T&gt; does not
inherit from QQmlGuard&lt;QObject&gt;, even if T inherits from QObject. As we
now can sipmly access the pointer from QQmlGuardImpl, we can side-step
any casting woes alltogether.

Moreover, we use this opportunity to let QQmlStrongJSObjectReference
drectly inherit from QQmlGuardImpl. This requires duplicating some of
the QQmlGuard API, but on the other hand avoids busy-work to hide no
longer desired API.

Unfortunately, we can no longer inherit privately from QQmlGuardImpl, as
otherwise the various subclasses can no longer cast the QQmlGuardImpl we
pass to them to their own type in the objectDestroyed(Impl) methods.

QQmlGuard(Impl) still could benefit from a move ctor/assignment
operator; those will be added in a later commit.

Task-number: QTBUG-45582
Change-Id: I995148a428e541ced5c79b3a61d91c4bb7e03308
Reviewed-by: Marc Mutz &lt;marc.mutz@qt.io&gt;
Reviewed-by: Qt CI Bot &lt;qt_ci_bot@qt-project.org&gt;
Reviewed-by: Ulf Hermann &lt;ulf.hermann@qt.io&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>QQmlAdaptorModel::setModel: clean up signature</title>
<updated>2022-02-02T23:52:49+00:00</updated>
<author>
<name>Fabian Kosmale</name>
<email>fabian.kosmale@qt.io</email>
</author>
<published>2022-02-01T15:17:37+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=1edfdbe00f9a2178b874fa558e3a653350a6c82f'/>
<id>1edfdbe00f9a2178b874fa558e3a653350a6c82f</id>
<content type='text'>
We no longer need the parent parameter.

Change-Id: I2687f051d51269abc0a74c4aafe77230ae9223c1
Reviewed-by: Ulf Hermann &lt;ulf.hermann@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We no longer need the parent parameter.

Change-Id: I2687f051d51269abc0a74c4aafe77230ae9223c1
Reviewed-by: Ulf Hermann &lt;ulf.hermann@qt.io&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>QQmlAdaptorModel: Do not use reparenting for lifetime managemment</title>
<updated>2022-02-02T12:23:36+00:00</updated>
<author>
<name>Fabian Kosmale</name>
<email>fabian.kosmale@qt.io</email>
</author>
<published>2022-01-31T13:14:26+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=6901eacff40a7d8781e20fb5bcfd28d7526b589b'/>
<id>6901eacff40a7d8781e20fb5bcfd28d7526b589b</id>
<content type='text'>
In QQmlAdaptorModel, we were using QQmlStrongJSQObjectReference to
ensure that a passed in model lives long enough. However,
QQmlAdaptorModel uses reparenting to keep objects alive. This is not
safe, as we can use QML singletons as models.

Reparenting singletons messes with the engine's lifetime handling once
their new parent gets deleted: The object will be marked as
queuedForDeletion by QQmlData::markAsDeleted; consequently wasDeleted
returns true for the object, and any ScopedObject or ObjectWrapper will
return nullptr when we try to retrieve their underlying QObject.

The actual object probaly does not get deleted, as it is not placed in
the QML heap. Consequently the gc will ignore it.

This leads to a crash when the singleton is accessed in a different
place: We see that the object is non-null, create a ScopedObject for it,
and then try to later access the ScopedObject's underlying object
(assuming that it must be non-null, because we already checked for the
actual object being non-null). However, due to the reasons outlined
above, we actually receive a null pointer, and thus encounter a crash.

To avoid he issue, we change the lifetime management strategy: Instead
of using the parent to keep the object alive, we now use a
QV4::PersistentValue.

Fixes: QTBUG-100260
Pick-to: 6.2 6.3 5.15
Change-Id: I266e6ef94c4f079de3da2742d6fb8d61df5a64ce
Reviewed-by: Andrei Golubev &lt;andrei.golubev@qt.io&gt;
Reviewed-by: Ulf Hermann &lt;ulf.hermann@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In QQmlAdaptorModel, we were using QQmlStrongJSQObjectReference to
ensure that a passed in model lives long enough. However,
QQmlAdaptorModel uses reparenting to keep objects alive. This is not
safe, as we can use QML singletons as models.

Reparenting singletons messes with the engine's lifetime handling once
their new parent gets deleted: The object will be marked as
queuedForDeletion by QQmlData::markAsDeleted; consequently wasDeleted
returns true for the object, and any ScopedObject or ObjectWrapper will
return nullptr when we try to retrieve their underlying QObject.

The actual object probaly does not get deleted, as it is not placed in
the QML heap. Consequently the gc will ignore it.

This leads to a crash when the singleton is accessed in a different
place: We see that the object is non-null, create a ScopedObject for it,
and then try to later access the ScopedObject's underlying object
(assuming that it must be non-null, because we already checked for the
actual object being non-null). However, due to the reasons outlined
above, we actually receive a null pointer, and thus encounter a crash.

To avoid he issue, we change the lifetime management strategy: Instead
of using the parent to keep the object alive, we now use a
QV4::PersistentValue.

Fixes: QTBUG-100260
Pick-to: 6.2 6.3 5.15
Change-Id: I266e6ef94c4f079de3da2742d6fb8d61df5a64ce
Reviewed-by: Andrei Golubev &lt;andrei.golubev@qt.io&gt;
Reviewed-by: Ulf Hermann &lt;ulf.hermann@qt.io&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>QV4::Engine::toVariant: Use metatype instead of metatype id</title>
<updated>2021-03-25T20:25:28+00:00</updated>
<author>
<name>Fabian Kosmale</name>
<email>fabian.kosmale@qt.io</email>
</author>
<published>2021-03-24T14:36:37+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=d009c0088bac6da4d775345a60e33fee22af22ce'/>
<id>d009c0088bac6da4d775345a60e33fee22af22ce</id>
<content type='text'>
This way, we can avoid the costly id to metatype lookup in case where we
actually need the full metatype.

Task-number: QTBUG-88766
Change-Id: Ibe29b323007f00d2f8d1807fb9b64f9a8f87e807
Reviewed-by: Ulf Hermann &lt;ulf.hermann@qt.io&gt;
Reviewed-by: Andrei Golubev &lt;andrei.golubev@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This way, we can avoid the costly id to metatype lookup in case where we
actually need the full metatype.

Task-number: QTBUG-88766
Change-Id: Ibe29b323007f00d2f8d1807fb9b64f9a8f87e807
Reviewed-by: Ulf Hermann &lt;ulf.hermann@qt.io&gt;
Reviewed-by: Andrei Golubev &lt;andrei.golubev@qt.io&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove QQmlEnginePrivate::isQObject</title>
<updated>2021-03-05T14:54:53+00:00</updated>
<author>
<name>Fabian Kosmale</name>
<email>fabian.kosmale@qt.io</email>
</author>
<published>2021-03-05T10:30:18+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=483d09779c2719415c5ac421074a1af3bd66ca29'/>
<id>483d09779c2719415c5ac421074a1af3bd66ca29</id>
<content type='text'>
The only caller has a QMetaType available and can query that one. This
leads to subsequent cleanups in QQmlListAccessor::setList and
QQmlAdaptorModel::setModel which now no longer have a need to pass the
QQmlEngine along.

Task-number: QTBUG-82931
Change-Id: I6f38892a3a5098f07bc21f4eebcca82cf52a6838
Reviewed-by: Ulf Hermann &lt;ulf.hermann@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The only caller has a QMetaType available and can query that one. This
leads to subsequent cleanups in QQmlListAccessor::setList and
QQmlAdaptorModel::setModel which now no longer have a need to pass the
QQmlEngine along.

Task-number: QTBUG-82931
Change-Id: I6f38892a3a5098f07bc21f4eebcca82cf52a6838
Reviewed-by: Ulf Hermann &lt;ulf.hermann@qt.io&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Adjust to QMetaObjectBuilder::MetaObjectFlags change</title>
<updated>2020-10-21T07:01:00+00:00</updated>
<author>
<name>Fabian Kosmale</name>
<email>fabian.kosmale@qt.io</email>
</author>
<published>2020-10-20T17:13:27+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=e62f97f5f824436ebc178f5bf332d5b9b08ee118'/>
<id>e62f97f5f824436ebc178f5bf332d5b9b08ee118</id>
<content type='text'>
Change-Id: I2f9b39fda6c25e57985a32864c85a50b7d6d0231
Reviewed-by: Volker Hilsheimer &lt;volker.hilsheimer@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Change-Id: I2f9b39fda6c25e57985a32864c85a50b7d6d0231
Reviewed-by: Volker Hilsheimer &lt;volker.hilsheimer@qt.io&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge remote-tracking branch 'origin/5.15' into dev</title>
<updated>2020-02-21T08:00:37+00:00</updated>
<author>
<name>Qt Forward Merge Bot</name>
<email>qt_forward_merge_bot@qt-project.org</email>
</author>
<published>2020-02-21T00:00:10+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=f6808f89a8c17e046f53b0bb5ff36cd9e24e9772'/>
<id>f6808f89a8c17e046f53b0bb5ff36cd9e24e9772</id>
<content type='text'>
 Conflicts:
	tests/auto/quick/qquickmousearea/BLACKLIST

Change-Id: I3de2c6377d57f5f9204d2cfc688d50a7a0b4150c
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
 Conflicts:
	tests/auto/quick/qquickmousearea/BLACKLIST

Change-Id: I3de2c6377d57f5f9204d2cfc688d50a7a0b4150c
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge remote-tracking branch 'origin/5.14' into 5.15</title>
<updated>2020-02-20T00:00:07+00:00</updated>
<author>
<name>Qt Forward Merge Bot</name>
<email>qt_forward_merge_bot@qt-project.org</email>
</author>
<published>2020-02-20T00:00:07+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=87d9234d71122f0332c37c81ca0338ddcda7eeba'/>
<id>87d9234d71122f0332c37c81ca0338ddcda7eeba</id>
<content type='text'>
Change-Id: I024445b3401a57040d7d67780ea32d2f8b02f41a
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Change-Id: I024445b3401a57040d7d67780ea32d2f8b02f41a
</pre>
</div>
</content>
</entry>
<entry>
<title>QQmlAdaptorModel: Don't const_cast to call release()</title>
<updated>2020-02-19T08:29:10+00:00</updated>
<author>
<name>Ulf Hermann</name>
<email>ulf.hermann@qt.io</email>
</author>
<published>2020-02-18T14:20:38+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=9b5bd48fc652a7dd47c545db8338a580592f7f35'/>
<id>9b5bd48fc652a7dd47c545db8338a580592f7f35</id>
<content type='text'>
release() is const.

Change-Id: I00171af75151741e725cd2ceaa80afcaac4f62a3
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
release() is const.

Change-Id: I00171af75151741e725cd2ceaa80afcaac4f62a3
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge remote-tracking branch 'origin/5.15' into dev</title>
<updated>2020-02-17T09:21:59+00:00</updated>
<author>
<name>Qt Forward Merge Bot</name>
<email>qt_forward_merge_bot@qt-project.org</email>
</author>
<published>2020-02-17T00:01:00+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=3e758800b4daf8fbc870a2ff5d54fce9d4402ce8'/>
<id>3e758800b4daf8fbc870a2ff5d54fce9d4402ce8</id>
<content type='text'>
 Conflicts:
	src/imports/qtqml/plugin.cpp
	src/qml/qml/qqml.h
	src/qml/qml/qqmlmetatype.cpp
	src/qml/qml/qqmlmetatype_p.h
	src/qml/qml/qqmltypeloader.cpp
	src/qml/types/qqmlbind.cpp
	src/quick/items/qquickitemsmodule.cpp
	tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp

Change-Id: I52548938a582cb6510271ed4bc3a9aa0c3c11df6
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
 Conflicts:
	src/imports/qtqml/plugin.cpp
	src/qml/qml/qqml.h
	src/qml/qml/qqmlmetatype.cpp
	src/qml/qml/qqmlmetatype_p.h
	src/qml/qml/qqmltypeloader.cpp
	src/qml/types/qqmlbind.cpp
	src/quick/items/qquickitemsmodule.cpp
	tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp

Change-Id: I52548938a582cb6510271ed4bc3a9aa0c3c11df6
</pre>
</div>
</content>
</entry>
</feed>
