summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@nokia.com>2012-01-24 15:48:10 +0100
committerTim Jenssen <tim.jenssen@nokia.com>2012-01-24 18:01:51 +0100
commitce22ca6ae677fa0f8b9ec96b32e3897b252c2670 (patch)
tree0af5396d806f393819d4cdfdd7770d6d53bc9e75
parent79450ce6532ad5567617fab9d8e64512189672b7 (diff)
Fix crash while deleting components.
To delete it's childs, the component uses qDeleteAll on the childs list, but once a child get's deleted it removes itself from the calling components child list and then messes up the list iterators. The child list passed to qDeleteAll needs to be a deep copy of the list the component owns to not mess with the original the calliing component holds. Change-Id: I638ffbb576a9543b7197c8bf267239f31197e274 Reviewed-by: Karsten Heimrich <karsten.heimrich@nokia.com>
-rw-r--r--installerbuilder/libinstaller/component.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/installerbuilder/libinstaller/component.cpp b/installerbuilder/libinstaller/component.cpp
index b0284286e..2398a7c62 100644
--- a/installerbuilder/libinstaller/component.cpp
+++ b/installerbuilder/libinstaller/component.cpp
@@ -94,8 +94,14 @@ Component::~Component()
if (!d->m_newlyInstalled)
qDeleteAll(d->m_operations);
- qDeleteAll(d->m_allChildComponents);
+ //we need to copy the list, because we are changing it with removeAll at top
+ //(this made the iterators broken in the past)
+ QList<Component*> copiedChildrenList = d->m_allChildComponents;
+ copiedChildrenList.detach(); //this makes it a real copy
+
+ qDeleteAll(copiedChildrenList);
delete d;
+ d = 0;
}
void Component::loadDataFromPackage(const LocalPackage &package)