diff --git a/Base/QTCore/qSlicerExtensionsManagerModel.cxx b/Base/QTCore/qSlicerExtensionsManagerModel.cxx index 5926d50210b..552f9299f2e 100644 --- a/Base/QTCore/qSlicerExtensionsManagerModel.cxx +++ b/Base/QTCore/qSlicerExtensionsManagerModel.cxx @@ -1714,13 +1714,22 @@ bool qSlicerExtensionsManagerModel::downloadAndInstallExtensionByName(const QStr } //----------------------------------------------------------------------------- -bool qSlicerExtensionsManagerModel::installExtensionFromServer(const QString& extensionName, bool restart) +bool qSlicerExtensionsManagerModel::installExtensionFromServer(const QString& extensionName, bool restart, bool update) { Q_D(qSlicerExtensionsManagerModel); if (this->isExtensionInstalled(extensionName)) { - // Already installed; nothing to do + if (update) + { + // Ensure extension metadata is retrieved from the server or cache. + if (!this->updateExtensionsMetadataFromServer(/* force= */ true, /* waitForCompletion= */ true)) + { + return false; + } + this->checkForExtensionsUpdates(); + this->scheduleExtensionForUpdate(extensionName); + } return true; } diff --git a/Base/QTCore/qSlicerExtensionsManagerModel.h b/Base/QTCore/qSlicerExtensionsManagerModel.h index 6540915496a..c65adce3bb0 100644 --- a/Base/QTCore/qSlicerExtensionsManagerModel.h +++ b/Base/QTCore/qSlicerExtensionsManagerModel.h @@ -398,15 +398,22 @@ public slots: /// To prevent the application from automatically restarting after the /// installation is completed, set the \a restart parameter to false. /// + /// To schedule the update of the extension and its dependencies to + /// the latest version available if already installed, set the \a update + /// parameter to true. + /// The update will take effect during the next application restart. + /// /// \param extensionName The name of the extension to be installed. /// \param restart Set to false to prevent automatic application restart (default: true). + /// \param update Set to true to schedule the extension for an update on the next application restart (default: false). /// /// \return \c true if the extension is successfully installed or already installed. /// /// \sa setInteractive /// \sa isExtensionInstalled, installExtension, updateExtensionsMetadataFromServer, downloadAndInstallExtensionByName + /// \sa scheduleExtensionForUpdate /// \sa qSlicerCoreApplication::testAttribute, qSlicerCoreApplication::AA_EnableTesting, qSlicerCoreApplication::restart - bool installExtensionFromServer(const QString& extensionName, bool restart = true); + bool installExtensionFromServer(const QString& extensionName, bool restart = true, bool update = false); /// \brief Schedule \a extensionName of uninstall /// Tell the application to uninstall \a extensionName when it will restart