From 3186833a44c689ef6a7f11082fbfce84a316230e Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 16 Oct 2016 17:28:17 +0200 Subject: [PATCH] Changed: Always launch the more recent version of Installer --- .../client/ryzom_installer/src/configfile.cpp | 27 ++++++++++++++----- .../client/ryzom_installer/src/configfile.h | 2 +- .../tools/client/ryzom_installer/src/main.cpp | 9 ++++++- .../client/ryzom_installer/src/operation.h | 1 + .../ryzom_installer/src/operationdialog.cpp | 1 + 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 94feeed9f..839c85272 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -727,12 +727,13 @@ bool CConfigFile::shouldCreateMenuShortcut() const return !shortcutExists(profile.getClientMenuShortcutFullPath()); } -bool CConfigFile::shouldCopyInstaller() const +int CConfigFile::compareInstallersVersion() const { + // returns 0 if same version, 1 if current installer is more recent, -1 if installed installer is more recent QString installerDst = getInstallationDirectory() + "/" + m_installerFilename; - // if installer not found in installation directory, extract it from BNP - if (!QFile::exists(installerDst)) return true; + // if installer not found in installation directory + if (!QFile::exists(installerDst)) return 1; QString installedVersion = getVersionFromExecutable(installerDst); QString newVersion = QApplication::applicationVersion(); @@ -740,8 +741,11 @@ bool CConfigFile::shouldCopyInstaller() const QVersionNumber installedVer = QVersionNumber::fromString(installedVersion); QVersionNumber newVer = QVersionNumber::fromString(newVersion); - // if version is greater, copy it - return newVer > installedVer; + // same version + if (newVer == installedVer) return 0; + + // if version is greater or lower + return newVer > installedVer ? 1:-1; } QString CConfigFile::getInstallerCurrentFilePath() const @@ -959,7 +963,18 @@ OperationStep CConfigFile::getInstallNextStep() const } } - if (shouldCopyInstaller()) return CopyInstaller; + // current installer more recent than installed one + switch (compareInstallersVersion()) + { + // current installer more recent, copy it + case 1: return CopyInstaller; + + // current installer older, launch the more recent installer + case -1: return LaunchInstalledInstaller; + + // continue only if 0 + default: break; + } // no default profile if (profile.id.isEmpty()) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index 89aa6ce0a..a7b2a8919 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -104,7 +104,7 @@ public: bool foundTemporaryFiles(const QString &directory) const; bool shouldCreateDesktopShortcut() const; bool shouldCreateMenuShortcut() const; - bool shouldCopyInstaller() const; + int compareInstallersVersion() const; // installation choices bool use64BitsClient() const; diff --git a/code/ryzom/tools/client/ryzom_installer/src/main.cpp b/code/ryzom/tools/client/ryzom_installer/src/main.cpp index a4ec462d9..23b602284 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/main.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/main.cpp @@ -252,7 +252,14 @@ int main(int argc, char *argv[]) step = config.getInstallNextStep(); - if (step == Done) + if (step == LaunchInstalledInstaller) + { +#ifndef _DEBUG + // restart more recent installed Installer version + if (QProcess::startDetached(config.getInstallerOriginalFilePath(), QApplication::arguments())) return 0; +#endif + } + else if (step == Done) { #if defined(Q_OS_WIN) && !defined(_DEBUG) // restart Installer, so it could be copied in TEMP and allowed to update itself diff --git a/code/ryzom/tools/client/ryzom_installer/src/operation.h b/code/ryzom/tools/client/ryzom_installer/src/operation.h index 2db0ce559..6d039252a 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operation.h +++ b/code/ryzom/tools/client/ryzom_installer/src/operation.h @@ -64,6 +64,7 @@ enum OperationStep CleanFiles, ExtractBnpClient, CopyInstaller, + LaunchInstalledInstaller, UninstallOldClient, CreateProfile, CreateProfileShortcuts, diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index 2d592ef6e..25bbd9b17 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -199,6 +199,7 @@ void COperationDialog::processInstallNextStep() break; case Done: + case LaunchInstalledInstaller: acceptDelayed(); break;