From 8570c509f505a4b238905122645a80faa768adb5 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 2 Sep 2011 09:45:16 +1000 Subject: Fix leak in State element. If a state was destroyed while active, it would leak bindings. Task-number: QTBUG-21194 Reviewed-by: Aaron Kennedy --- src/declarative/util/qdeclarativestate.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index 9f56ccb..ee3d06b 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -173,6 +173,18 @@ QDeclarativeState::~QDeclarativeState() Q_D(QDeclarativeState); if (d->group) d->group->removeState(this); + + /* + destroying an active state does not return us to the + base state, so we need to clean up our revert list to + prevent leaks. In the future we may want to redconsider + this overall architecture. + */ + for (int i = 0; i < d->revertList.count(); ++i) { + if (d->revertList.at(i).binding()) { + d->revertList.at(i).binding()->destroy(); + } + } } /*! -- cgit v0.12