summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2011-06-08 15:38:56 +0200
committerkh1 <qt-info@nokia.com>2011-06-08 15:38:56 +0200
commit89a3637304553cfcd1418daad8290e5dea74779c (patch)
tree72b5f9d3a972f2efb8403c10c4f52523ad8495c0
parent919c7a85ff92361c737b1a4a9bd089b3ea023c16 (diff)
Uninstall not yet installed replacement removes the original.
Review-by: tjennsen
-rw-r--r--installerbuilder/libinstaller/qinstaller.cpp24
-rw-r--r--installerbuilder/libinstaller/qinstaller.h1
-rw-r--r--installerbuilder/libinstaller/qinstaller_p.cpp6
-rw-r--r--installerbuilder/libinstaller/qinstaller_p.h1
4 files changed, 25 insertions, 7 deletions
diff --git a/installerbuilder/libinstaller/qinstaller.cpp b/installerbuilder/libinstaller/qinstaller.cpp
index 7b396d435..f447b16f6 100644
--- a/installerbuilder/libinstaller/qinstaller.cpp
+++ b/installerbuilder/libinstaller/qinstaller.cpp
@@ -754,9 +754,8 @@ bool Installer::fetchAllPackages()
}
}
- // remove all components that got a replacement
- foreach (const QString &component, data.componentsToReplace)
- delete components.take(component);
+ // store all components that got a replacement
+ storeReplacedComponents(components, data.componentsToReplace);
// now append all components to their respective parents
QMap<QString, QInstaller::Component*>::const_iterator it;
@@ -893,9 +892,8 @@ bool Installer::fetchUpdaterPackages()
}
}
- // remove all components that got a replacement
- foreach (const QString &component, data.componentsToReplace)
- delete components.take(component);
+ // store all components that got a replacement
+ storeReplacedComponents(components, data.componentsToReplace);
// remove all unimportant components
QList<QInstaller::Component*> updaterComponents = components.values();
@@ -1778,3 +1776,17 @@ bool Installer::updateComponentData(struct Data &data, Component *component)
return true;
}
+
+void Installer::storeReplacedComponents(QMap<QString, Component*> &components, const QStringList &replaceables)
+{
+ // remeber all components that got a replacement, requierd for uninstall
+ foreach (const QString &componentName, replaceables) {
+ Component *component = components.take(componentName);
+ if (!component && !d->m_componentsToReplace.contains(componentName)) {
+ component = new Component(this);
+ component->setValue(QLatin1String("Name"), componentName);
+ }
+ if (component)
+ d->m_componentsToReplace.insert(componentName, component);
+ }
+}
diff --git a/installerbuilder/libinstaller/qinstaller.h b/installerbuilder/libinstaller/qinstaller.h
index a46cdfcf8..79be18f9c 100644
--- a/installerbuilder/libinstaller/qinstaller.h
+++ b/installerbuilder/libinstaller/qinstaller.h
@@ -282,6 +282,7 @@ private:
bool updateComponentData(struct Data &data, QInstaller::Component *component);
static Component *subComponentByName(const QInstaller::Installer *installer, const QString &name,
const QString &version = QString(), Component *check = 0);
+ void storeReplacedComponents(QMap<QString, Component*> &components, const QStringList &replaceables);
private:
InstallerPrivate* const d;
diff --git a/installerbuilder/libinstaller/qinstaller_p.cpp b/installerbuilder/libinstaller/qinstaller_p.cpp
index 8cca59af5..18b4beaf5 100644
--- a/installerbuilder/libinstaller/qinstaller_p.cpp
+++ b/installerbuilder/libinstaller/qinstaller_p.cpp
@@ -191,6 +191,7 @@ InstallerPrivate::~InstallerPrivate()
qDeleteAll(m_rootComponents);
qDeleteAll(m_updaterComponents);
qDeleteAll(m_updaterComponentsDeps);
+ qDeleteAll(m_componentsToReplace.values());
qDeleteAll(m_ownedOperations);
qDeleteAll(m_performedOperationsOld);
@@ -1558,7 +1559,10 @@ void InstallerPrivate::runUndoOperations(const QList<KDUpdater::UpdateOperation*
}
if (!componentName.isEmpty()) {
- if (Component *component = q->componentByName(componentName)) {
+ Component *component = q->componentByName(componentName);
+ if (!component)
+ component = m_componentsToReplace.value(componentName, 0);
+ if (component) {
component->setUninstalled();
packages->removePackage(component->name());
packages->writeToDisk();
diff --git a/installerbuilder/libinstaller/qinstaller_p.h b/installerbuilder/libinstaller/qinstaller_p.h
index e58bd72c8..281740058 100644
--- a/installerbuilder/libinstaller/qinstaller_p.h
+++ b/installerbuilder/libinstaller/qinstaller_p.h
@@ -177,6 +177,7 @@ public:
QList<Component*> m_rootComponents;
QList<Component*> m_updaterComponents;
QList<Component*> m_updaterComponentsDeps;
+ QHash<QString, Component*> m_componentsToReplace;
QList<KDUpdater::UpdateOperation*> m_ownedOperations;
QList<KDUpdater::UpdateOperation*> m_performedOperationsOld;