diff --git a/src/core/engine.cpp b/src/core/engine.cpp
--- a/src/core/engine.cpp
+++ b/src/core/engine.cpp
@@ -708,12 +708,10 @@
emit signalEntryChanged(entry);
qCDebug(KNEWSTUFFCORE) << "about to uninstall entry " << entry.uniqueId();
- // FIXME: change the status?
m_installation->uninstall(actualEntryForUninstall);
- entry.setStatus(KNS3::Entry::Deleted); //status for actual entry gets set in m_installation->uninstall()
+ entry.setStatus(actualEntryForUninstall.status());
emit signalEntryChanged(entry);
-
}
void Engine::loadDetails(const KNSCore::EntryInternal &entry)
diff --git a/src/core/installation.h b/src/core/installation.h
--- a/src/core/installation.h
+++ b/src/core/installation.h
@@ -114,16 +114,16 @@
* Uninstalls an entry. It reverses the steps which were performed
* during the installation.
*
- * The entry instance will be updated with any new information:
+ * The entry emitted by signalEntryChanged will be updated with any new information, in particular the following:
*
- * - Status will be set to Deleted
+ *
- Status will be set to Deleted, unless the uninstall
+ * script exists with an error and the user chooses to cancel the uninstallation
*
- uninstalledFiles will list files which were removed during uninstallation
*
- installedFiles will become empty
*
*
* @param entry The entry to deinstall
*
- * @note FIXME: I don't believe this works yet :)
*/
void uninstall(KNSCore::EntryInternal entry);
diff --git a/src/core/installation.cpp b/src/core/installation.cpp
--- a/src/core/installation.cpp
+++ b/src/core/installation.cpp
@@ -800,8 +800,23 @@
emit signalInstallationFailed(i18n("The removal of %1 failed, as there seems to somehow be more than one thing installed, which is not supposed to be possible for KPackage based entries.", entry.name()));
}
} else {
- entry.setStatus(KNS3::Entry::Deleted);
+ // If all the files are removed assume that the entry got manually removed
+ // otherwise there would be no way to delete the entry that editing the register
+ bool manuallyUninstalled = true;
+ const auto lst = entry.installedFiles();
+ for (const auto &file : lst) {
+ if (QFile::exists(file)) {
+ manuallyUninstalled = false;
+ break;
+ }
+ }
+ if (manuallyUninstalled) {
+ entry.setStatus(KNS3::Entry::Deleted);
+ emit signalEntryChanged(entry);
+ return;
+ }
+ // If there is an uninstall script, make sure it runs without errors
if (!uninstallCommand.isEmpty()) {
const auto lst = entry.installedFiles();
for (const QString &file : lst) {
@@ -811,21 +826,36 @@
QString command(uninstallCommand);
command.replace(QLatin1String("%f"), fileArg);
- QStringList args = KShell::splitArgs(command);
- const QString program = args.takeFirst();
- int exitcode = QProcess::execute(program, args);
-
- if (exitcode) {
- emit signalInstallationError(i18n("The uninstallation process failed to successfully run the command %1", command));
- qCCritical(KNEWSTUFFCORE) << "Command failed" << command;
- } else {
+ QStringList args = KShell::splitArgs(command);
+ const QString program = args.takeFirst();
+ QProcess process;
+ process.start(program, args);
+ process.waitForFinished(-1);
+
+ if (process.exitCode()) {
+ const QString processOutput = QString::fromLocal8Bit(process.readAllStandardError());
+ const QString err = i18n("The uninstallation process failed to successfully run the command %1\n"
+ "The output of was: \n%2\n"
+ "If you think this is incorrect, you can continue or cancel the uninstallation process",
+ KShell::quoteArg(command), processOutput);
+ emit signalInstallationError(err);
+ // Ask the user if he wants to continue, even though the script failed
+ Question question(Question::ContinueCancelQuestion);
+ question.setQuestion(err);
+ Question::Response response = question.ask();
+ if (response == Question::CancelResponse) {
+ // Use can delete files manually
+ entry.setStatus(KNS3::Entry::Installed);
+ emit signalEntryChanged(entry);
+ return;
+ }
+ } else {
qCDebug(KNEWSTUFFCORE) << "Command executed successfully: " << command;
}
}
}
}
- const auto lst = entry.installedFiles();
for (const QString &file : lst) {
if (file.endsWith(QLatin1Char('/'))) {
QDir dir;
@@ -856,6 +886,7 @@
}
entry.setUnInstalledFiles(entry.installedFiles());
entry.setInstalledFiles(QStringList());
+ entry.setStatus(KNS3::Entry::Deleted);
emit signalEntryChanged(entry);
}
}