From 3f110d2035a70ca29fb7f0fabfdbf7a744a6fb3b Mon Sep 17 00:00:00 2001 From: danteruiz Date: Tue, 29 Oct 2019 13:45:28 -0700 Subject: [PATCH] fix windows install process --- launchers/qt/src/Helper.cpp | 2 +- launchers/qt/src/LauncherInstaller_windows.cpp | 12 ++++++++---- launchers/qt/src/LauncherInstaller_windows.h | 2 +- launchers/qt/src/main.cpp | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/launchers/qt/src/Helper.cpp b/launchers/qt/src/Helper.cpp index d09088a0e6..fd12bf3af8 100644 --- a/launchers/qt/src/Helper.cpp +++ b/launchers/qt/src/Helper.cpp @@ -77,7 +77,7 @@ bool swapLaunchers(const QString& oldLauncherPath, const QString& newLauncherPat void cleanLogFile() { - QDir launcherDirectory = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); + QDir launcherDirectory = PathUtils::getLogsDirectory(); launcherDirectory.mkpath(launcherDirectory.absolutePath()); QString filename = launcherDirectory.absoluteFilePath("Log.txt"); QString tmpFilename = launcherDirectory.absoluteFilePath("Log-last.txt"); diff --git a/launchers/qt/src/LauncherInstaller_windows.cpp b/launchers/qt/src/LauncherInstaller_windows.cpp index 7ba8b8e2d2..78c7dadd2b 100644 --- a/launchers/qt/src/LauncherInstaller_windows.cpp +++ b/launchers/qt/src/LauncherInstaller_windows.cpp @@ -15,7 +15,7 @@ #include #include -LauncherInstaller::LauncherInstaller(const QString& applicationFilePath) { +LauncherInstaller::LauncherInstaller() { _launcherInstallDir = PathUtils::getLauncherDirectory(); _launcherApplicationsDir = PathUtils::getApplicationsDirectory(); qDebug() << "Launcher install dir: " << _launcherInstallDir.absolutePath(); @@ -23,7 +23,10 @@ LauncherInstaller::LauncherInstaller(const QString& applicationFilePath) { _launcherInstallDir.mkpath(_launcherInstallDir.absolutePath()); _launcherApplicationsDir.mkpath(_launcherApplicationsDir.absolutePath()); - QFileInfo fileInfo(applicationFilePath); + char appPath[MAX_PATH]; + GetModuleFileNameA(NULL, appPath, MAX_PATH); + QString applicationRunningPath = appPath; + QFileInfo fileInfo(applicationRunningPath); _launcherRunningFilePath = fileInfo.absoluteFilePath(); _launcherRunningDirPath = fileInfo.absoluteDir().absolutePath(); qDebug() << "Launcher running file path: " << _launcherRunningFilePath; @@ -44,11 +47,12 @@ void LauncherInstaller::install() { bool didRemove = QFile::remove(oldLauncherPath); qDebug() << "did remove file: " << didRemove; } + qDebug() << "Current launcher location: " << _launcherRunningFilePath; bool success = QFile::copy(_launcherRunningFilePath, oldLauncherPath); if (success) { - qDebug() << "successful"; + qDebug() << "Launcher installed: " << oldLauncherPath; } else { - qDebug() << "not successful"; + qDebug() << "Failed to install: " << oldLauncherPath; } deleteShortcuts(); diff --git a/launchers/qt/src/LauncherInstaller_windows.h b/launchers/qt/src/LauncherInstaller_windows.h index 3bd9d0242a..ffb402cce5 100644 --- a/launchers/qt/src/LauncherInstaller_windows.h +++ b/launchers/qt/src/LauncherInstaller_windows.h @@ -3,7 +3,7 @@ #include class LauncherInstaller { public: - LauncherInstaller(const QString& applicationFilePath); + LauncherInstaller(); ~LauncherInstaller() = default; void install(); diff --git a/launchers/qt/src/main.cpp b/launchers/qt/src/main.cpp index 3918ec944e..42a6229d1f 100644 --- a/launchers/qt/src/main.cpp +++ b/launchers/qt/src/main.cpp @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) { } #ifdef Q_OS_WIN - LauncherInstaller launcherInstaller(argv[0]); + LauncherInstaller launcherInstaller; if (options->contains("--uninstall") || options->contains("--resumeUninstall")) { launcherInstaller.uninstall(); return 0;