diff options
Diffstat (limited to 'src/manager-lib')
-rw-r--r-- | src/manager-lib/application.cpp | 16 | ||||
-rw-r--r-- | src/manager-lib/application.h | 4 | ||||
-rw-r--r-- | src/manager-lib/applicationmanager.cpp | 27 |
3 files changed, 25 insertions, 22 deletions
diff --git a/src/manager-lib/application.cpp b/src/manager-lib/application.cpp index 4eff6990..e4cb7292 100644 --- a/src/manager-lib/application.cpp +++ b/src/manager-lib/application.cpp @@ -417,25 +417,20 @@ QVector<AbstractApplication *> AbstractApplication::fromApplicationInfoVector( // There's already another ApplicationInfo with the same id. It's probably an update for a // built-in app, in which case we use the same Application instance to hold both // ApplicationInfo instances. - bool merged = false; - if (!otherAbsApp->isAlias()) { auto otherApp = static_cast<Application*>(otherAbsApp); auto fullAppInfo = static_cast<ApplicationInfo*>(appInfo); if (otherApp->isBuiltIn() && !fullAppInfo->isBuiltIn() && !otherApp->updatedInfo()) { otherApp->setUpdatedInfo(static_cast<ApplicationInfo*>(appInfo)); - merged = true; } else if (!otherApp->isBuiltIn() && fullAppInfo->isBuiltIn() && !otherApp->updatedInfo()) { auto currentBaseInfo = otherApp->takeBaseInfo(); otherApp->setBaseInfo(static_cast<ApplicationInfo*>(appInfo)); otherApp->setUpdatedInfo(currentBaseInfo); - merged = true; } + } else { + qCWarning(LogSystem) << "Found a second application with id" << appInfo->id() + << "which is not an update for a built-in one. Ignoring it."; } - - if (!merged) - qCWarning(LogSystem).nospace() << "Found a second application with id " - << appInfo->id() << " which is not an update for a built-in one. Ignoring it."; } else { app.reset(new Application(static_cast<ApplicationInfo*>(appInfo))); } @@ -564,6 +559,11 @@ void Application::setUpdatedInfo(ApplicationInfo* info) emit bulkChange(); } +ApplicationInfo *Application::takeUpdatedInfo() +{ + return m_updatedInfo.take(); +} + void Application::setState(State state) { if (m_state != state) { diff --git a/src/manager-lib/application.h b/src/manager-lib/application.h index 673cdfe5..b5c62338 100644 --- a/src/manager-lib/application.h +++ b/src/manager-lib/application.h @@ -201,9 +201,11 @@ public: removed when requested. */ void setBaseInfo(ApplicationInfo*); + AbstractApplicationInfo *baseInfo() const { return m_info.data(); } + ApplicationInfo *takeBaseInfo(); void setUpdatedInfo(ApplicationInfo*); ApplicationInfo *updatedInfo() const { return m_updatedInfo.data(); } - ApplicationInfo *takeBaseInfo(); + ApplicationInfo *takeUpdatedInfo(); void setState(State); void setProgress(qreal); diff --git a/src/manager-lib/applicationmanager.cpp b/src/manager-lib/applicationmanager.cpp index b2745ecb..dc6071d9 100644 --- a/src/manager-lib/applicationmanager.cpp +++ b/src/manager-lib/applicationmanager.cpp @@ -1203,16 +1203,10 @@ bool ApplicationManager::startingApplicationInstallation(ApplicationInfo *info) if (!blockApplication(app->id())) return false; - if (app->isBuiltIn()) { - // overlay the existing base info - // we will rollback to the base one if this update is removed. - app->setUpdatedInfo(newInfo.take()); - } else { - // overwrite the existing base info - // we're not keeping track of the original. so removing the updated base version removes the - // application entirely. - app->setBaseInfo(newInfo.take()); - } + // There is still an issue with "shadowing" built-in apps (which will be properly fixed in 5.14): + // As the updatedInfo might be used already (by an already updated built-in app), we cannot revert back any + // more to the previous version. Canceling the update will therefore revert back to the original app. + app->setUpdatedInfo(newInfo.take()); app->setState(Application::BeingUpdated); app->setProgress(0); emitDataChanged(app); @@ -1290,8 +1284,11 @@ bool ApplicationManager::finishedApplicationInstall(const QString &id) case Application::Installed: return false; - case Application::BeingInstalled: - case Application::BeingUpdated: { + case Application::BeingUpdated: + if (!static_cast<ApplicationInfo*>(app->baseInfo())->isBuiltIn()) + app->setBaseInfo(app->takeUpdatedInfo()); + Q_FALLTHROUGH(); + case Application::BeingInstalled: { // The Application object has been updated right at the start of the installation/update. // Now's the time to update the InstallationReport that was written by the installer. QFile irfile(QDir(app->nonAliasedInfo()->manifestDir()).absoluteFilePath(qSL("installation-report.yaml"))); @@ -1316,6 +1313,8 @@ bool ApplicationManager::finishedApplicationInstall(const QString &id) app->setUpdatedInfo(nullptr); app->setState(Application::Installed); registerMimeTypes(); + emitDataChanged(app); + unblockApplication(id); break; case Application::BeingRemoved: { int row = d->apps.indexOf(app); @@ -1361,11 +1360,13 @@ bool ApplicationManager::canceledApplicationInstall(const QString &id) break; } case Application::BeingUpdated: + app->setUpdatedInfo(nullptr); + Q_FALLTHROUGH(); case Application::BeingDowngraded: case Application::BeingRemoved: app->setState(Application::Installed); app->setProgress(0); - emitDataChanged(app, QVector<int> { IsUpdating }); + emitDataChanged(app); unblockApplication(id); break; |