Changed: Always launch the more recent version of Installer

This commit is contained in:
kervala 2016-10-16 17:28:17 +02:00
parent 5b6c0285cd
commit 3186833a44
5 changed files with 32 additions and 8 deletions

View file

@ -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())

View file

@ -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;

View file

@ -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

View file

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

View file

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