mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-27 11:00:54 +00:00
Changed: Always launch the more recent version of Installer
This commit is contained in:
parent
a2f67bf469
commit
fe890b3728
5 changed files with 32 additions and 8 deletions
|
@ -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())
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -64,6 +64,7 @@ enum OperationStep
|
|||
CleanFiles,
|
||||
ExtractBnpClient,
|
||||
CopyInstaller,
|
||||
LaunchInstalledInstaller,
|
||||
UninstallOldClient,
|
||||
CreateProfile,
|
||||
CreateProfileShortcuts,
|
||||
|
|
|
@ -199,6 +199,7 @@ void COperationDialog::processInstallNextStep()
|
|||
break;
|
||||
|
||||
case Done:
|
||||
case LaunchInstalledInstaller:
|
||||
acceptDelayed();
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue