Skip to content

Commit

Permalink
Fix memory leak with deferred properties
Browse files Browse the repository at this point in the history
This is a regression introduced with commit
3b6eeee in the 5.9 branch. When
constructing an object with deferred properties and not running
qmlExecuteDeferred, then the deferred data would never get deleted
because the bindings list remains non-empty and we would leak the
deferred data as well as the entire compilation unit behind it.

This happens for example when declaring when instantiating a QML file
with states:

   states: [ State { ... }, State { ... }, ... }

Unless every state is entered, its deferred changes property is never
applied (via qmlExecuteDeferred) and thus the defer data is leaked.

Task-number: QTBUG-66189
Change-Id: I1b2119c601d1e0ab4e37f53d4cf2f569586ee883
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
  • Loading branch information
tronical committed Feb 6, 2018
1 parent 5b0a98f commit c6b3c69
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/qml/qml/qqmlengine.cpp
Expand Up @@ -1763,7 +1763,8 @@ void QQmlData::destroyed(QObject *object)

compilationUnit = nullptr;

releaseDeferredData();
qDeleteAll(deferredData);
deferredData.clear();

QQmlBoundSignal *signalHandler = signalHandlers;
while (signalHandler) {
Expand Down

0 comments on commit c6b3c69

Please sign in to comment.