From 5a5f91a97d8af4c17e264e6c1894843e740364e3 Mon Sep 17 00:00:00 2001 From: kh1 Date: Tue, 8 Nov 2011 16:38:47 +0100 Subject: Make sure we remove ui elements we added. This fixes several problems, e.g. once a component script has been run, possible ui elements or even complete pages have been added. On a second component script run these elements would have been added again etc... Now we remove all pages and widget by default. Change-Id: I47a3283ce06767c28529201432b71c0b4f12e533 Reviewed-by: Niels Weber Reviewed-by: Alexander Lenhardt Reviewed-by: Tim Jenssen --- installerbuilder/libinstaller/component_p.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'installerbuilder/libinstaller/component_p.cpp') diff --git a/installerbuilder/libinstaller/component_p.cpp b/installerbuilder/libinstaller/component_p.cpp index fb63f6d6f..a6e34aa02 100644 --- a/installerbuilder/libinstaller/component_p.cpp +++ b/installerbuilder/libinstaller/component_p.cpp @@ -59,6 +59,22 @@ ComponentPrivate::ComponentPrivate(PackageManagerCore *core, Component *qq) { } +ComponentPrivate::~ComponentPrivate() +{ + // Before we can delete the added widgets, they need to be removed from the wizard first. + QMap >::const_iterator it; + foreach (const QString &widgetName, m_userInterfaces.keys()) { + m_core->removeWizardPage(q, widgetName); + m_core->removeWizardPageItem(q, widgetName); + } + + // Use QPointer here instead of raw pointers. This is a requirement that needs to be met cause possible + // Ui elements get added during component script run and might be destroyed by the package manager gui + // before the actual component gets destroyed. Avoids a possible delete call on a dangling pointer. + foreach (const QPointer widget, m_userInterfaces) + delete widget.data(); +} + void ComponentPrivate::init() { // register translation stuff -- cgit v1.2.3