Changed: Always launch the more recent version of Installer

--HG--
branch : develop
This commit is contained in:
kervala 2016-10-16 17:28:17 +02:00
parent f65883296b
commit a5a488da3e
5 changed files with 32 additions and 8 deletions

View file

@ -727,12 +727,13 @@ bool CConfigFile::shouldCreateMenuShortcut() const
return !shortcutExists(profile.getClientMenuShortcutFullPath()); 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; QString installerDst = getInstallationDirectory() + "/" + m_installerFilename;
// if installer not found in installation directory, extract it from BNP // if installer not found in installation directory
if (!QFile::exists(installerDst)) return true; if (!QFile::exists(installerDst)) return 1;
QString installedVersion = getVersionFromExecutable(installerDst); QString installedVersion = getVersionFromExecutable(installerDst);
QString newVersion = QApplication::applicationVersion(); QString newVersion = QApplication::applicationVersion();
@ -740,8 +741,11 @@ bool CConfigFile::shouldCopyInstaller() const
QVersionNumber installedVer = QVersionNumber::fromString(installedVersion); QVersionNumber installedVer = QVersionNumber::fromString(installedVersion);
QVersionNumber newVer = QVersionNumber::fromString(newVersion); QVersionNumber newVer = QVersionNumber::fromString(newVersion);
// if version is greater, copy it // same version
return newVer > installedVer; if (newVer == installedVer) return 0;
// if version is greater or lower
return newVer > installedVer ? 1:-1;
} }
QString CConfigFile::getInstallerCurrentFilePath() const 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 // no default profile
if (profile.id.isEmpty()) if (profile.id.isEmpty())

View file

@ -104,7 +104,7 @@ public:
bool foundTemporaryFiles(const QString &directory) const; bool foundTemporaryFiles(const QString &directory) const;
bool shouldCreateDesktopShortcut() const; bool shouldCreateDesktopShortcut() const;
bool shouldCreateMenuShortcut() const; bool shouldCreateMenuShortcut() const;
bool shouldCopyInstaller() const; int compareInstallersVersion() const;
// installation choices // installation choices
bool use64BitsClient() const; bool use64BitsClient() const;

View file

@ -252,7 +252,14 @@ int main(int argc, char *argv[])
step = config.getInstallNextStep(); 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) #if defined(Q_OS_WIN) && !defined(_DEBUG)
// restart Installer, so it could be copied in TEMP and allowed to update itself // restart Installer, so it could be copied in TEMP and allowed to update itself

View file

@ -64,6 +64,7 @@ enum OperationStep
CleanFiles, CleanFiles,
ExtractBnpClient, ExtractBnpClient,
CopyInstaller, CopyInstaller,
LaunchInstalledInstaller,
UninstallOldClient, UninstallOldClient,
CreateProfile, CreateProfile,
CreateProfileShortcuts, CreateProfileShortcuts,

View file

@ -199,6 +199,7 @@ void COperationDialog::processInstallNextStep()
break; break;
case Done: case Done:
case LaunchInstalledInstaller:
acceptDelayed(); acceptDelayed();
break; break;