diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 345dd80bc..6e978cd80 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -722,11 +722,28 @@ bool CConfigFile::shouldCreateMenuShortcut() const return !shortcut.isEmpty() && !NLMISC::CFile::isExists(qToUtf8(shortcut)); } -QString CConfigFile::getInstallerFullPath() const +QString CConfigFile::getInstallerCurrentFilePath() const { + // installer is always run from TEMP under Windows + return QApplication::applicationFilePath(); +} + +QString CConfigFile::getInstallerCurrentDirPath() const +{ + // installer is always run from TEMP under Windows return QApplication::applicationDirPath(); } +QString CConfigFile::getInstallerOriginalFilePath() const +{ + return getInstallerOriginalDirPath() + "/" + QFileInfo(QApplication::applicationFilePath()).fileName(); +} + +QString CConfigFile::getInstallerOriginalDirPath() const +{ + return m_installationDirectory; +} + QString CConfigFile::getInstallerMenuLinkFullPath() const { #ifdef Q_OS_WIN32 diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index 058e5c475..b2a4ae7e5 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -113,7 +113,11 @@ public: QString getClientArch() const; - QString getInstallerFullPath() const; + QString getInstallerCurrentFilePath() const; + QString getInstallerCurrentDirPath() const; + QString getInstallerOriginalFilePath() const; + QString getInstallerOriginalDirPath() const; + QString getInstallerMenuLinkFullPath() const; QStringList getInstallerRequiredFiles() const; diff --git a/code/ryzom/tools/client/ryzom_installer/src/main.cpp b/code/ryzom/tools/client/ryzom_installer/src/main.cpp index 481c15bff..2e4ad5481 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/main.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/main.cpp @@ -120,6 +120,24 @@ int main(int argc, char *argv[]) return 1; } +#if defined(Q_OS_WIN) && !defined(_DEBUG) + // under Windows, Ryzom Installer should always be copied in TEMP directory + QString tempPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation); + + // check if launched from TEMP directory + if (step == Done && QApplication::applicationDirPath() != tempPath) + { + // copy installer and required files to TEMP directory + if (copyInstallerFiles(config.getInstallerRequiredFiles(), tempPath)) + { + QString tempFile = tempPath + "/" + QFileInfo(QApplication::applicationFilePath()).fileName(); + + // launch copy in TEMP directory with same arguments + if (QProcess::startDetached(tempFile, QApplication::arguments())) return 0; + } + } +#endif + // use product name from ryzom_installer.ini if (!config.getProductName().isEmpty()) QApplication::setApplicationName(config.getProductName()); @@ -141,23 +159,6 @@ int main(int argc, char *argv[]) if (parser.isSet(uninstallOption)) { -#if defined(Q_OS_WIN) && !defined(_DEBUG) - QString tempPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation); - - // check if launched from TEMP directory - if (QApplication::applicationDirPath() != tempPath) - { - // copy installer and required files to TEMP directory - if (copyInstallerFiles(config.getInstallerRequiredFiles(), tempPath)) - { - QString tempFile = tempPath + "/" + QFileInfo(QApplication::applicationFilePath()).fileName(); - - // launch copy in TEMP directory with same arguments - if (QProcess::startDetached(tempFile, QApplication::arguments())) return 0; - } - } -#endif - SComponents components; // add all servers by default diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index c706dba84..da7a2f52d 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -1135,7 +1135,7 @@ void COperationDialog::deleteComponentsInstaller() dir.removeRecursively(); } - path = config->getInstallerFullPath(); + path = config->getInstallerOriginalDirPath(); QStringList files = config->getInstallerRequiredFiles(); foreach(const QString &file, files) @@ -1143,7 +1143,7 @@ void COperationDialog::deleteComponentsInstaller() QString fullPath = path + "/" + file; // delete file - if (!QFile::remove(fullPath)) + if (QFile::exists(fullPath) && !QFile::remove(fullPath)) { #ifdef Q_OS_WIN32 // under Windows, a running executable is locked, so we need to delete it later