mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 19:47:46 -07:00
[App][Windows][NSIS] Use QProcess::setNativeArguments on Windows, properly order portable detection (#6989)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
(cherry picked from commit dfbe944c31)
This commit is contained in:
parent
2bb91df139
commit
5bbdb0bd78
2 changed files with 23 additions and 6 deletions
|
|
@ -117,21 +117,22 @@ ${If} $InstDir == ""
|
||||||
; we need to set a default based on the install mode
|
; we need to set a default based on the install mode
|
||||||
StrCpy $InstDir $0
|
StrCpy $InstDir $0
|
||||||
${EndIf}
|
${EndIf}
|
||||||
Call SetModeDestinationFromInstdir
|
|
||||||
|
|
||||||
; --- Detect portable install when using /R ---
|
; --- Detect portable install when using /R (must come BEFORE SetModeDestinationFromInstdir) ---
|
||||||
${If} $ReinstallMode = 1
|
${If} $ReinstallMode = 1
|
||||||
IfFileExists "$InstDir\portable.dat" 0 not_portable
|
IfFileExists "$InstDir\portable.dat" 0 not_portable
|
||||||
StrCpy $PortableMode 1
|
StrCpy $PortableMode 1
|
||||||
Goto portable_done
|
Goto portable_done
|
||||||
|
|
||||||
not_portable:
|
not_portable:
|
||||||
StrCpy $PortableMode 0
|
StrCpy $PortableMode 0
|
||||||
|
|
||||||
portable_done:
|
portable_done:
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
|
; Now that $PortableMode reflects reality, commit InstDir into the correct slot
|
||||||
|
Call SetModeDestinationFromInstdir
|
||||||
|
|
||||||
${If} $ReinstallMode = 1
|
${If} $ReinstallMode = 1
|
||||||
|
${AndIf} $PortableMode = 0
|
||||||
Call AutoUninstallIfNeeded
|
Call AutoUninstallIfNeeded
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -219,9 +219,25 @@ void DlgUpdate::downloadError(const QString &errorString)
|
||||||
void DlgUpdate::downloadSuccessful(const QUrl &filepath)
|
void DlgUpdate::downloadSuccessful(const QUrl &filepath)
|
||||||
{
|
{
|
||||||
setLabel(tr("Installing..."));
|
setLabel(tr("Installing..."));
|
||||||
|
|
||||||
|
QString installerPath = filepath.toLocalFile();
|
||||||
|
|
||||||
|
QString appDir = QDir::toNativeSeparators(QCoreApplication::applicationDirPath());
|
||||||
|
QProcess process;
|
||||||
|
process.setProgram(installerPath);
|
||||||
|
|
||||||
|
// NSIS needs the /D= argument to be an UNQUOTED string, even if it contains spaces. Qt likes to quote arguments if
|
||||||
|
// they contain spaces, so we use the windows exclusive QProcess::setNativeArguments in the only case where this is
|
||||||
|
// relevant, which preserves the argument unquoted.
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
process.setNativeArguments(QString("/R /D=%1").arg(appDir));
|
||||||
|
#else
|
||||||
|
// Linux/macOS: normal argument passing (not relevant since they update differently.)
|
||||||
|
process.setArguments({"/R", QString("/D=%1").arg(appDir)});
|
||||||
|
#endif
|
||||||
|
|
||||||
// Try to open the installer. If it opens, quit Cockatrice
|
// Try to open the installer. If it opens, quit Cockatrice
|
||||||
if (QProcess::startDetached(
|
if (process.startDetached()) {
|
||||||
QString("\"%1\" /R /D=\"%2\"").arg(filepath.toLocalFile(), QCoreApplication::applicationDirPath()))) {
|
|
||||||
QMetaObject::invokeMethod(static_cast<MainWindow *>(parent()), "close", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(static_cast<MainWindow *>(parent()), "close", Qt::QueuedConnection);
|
||||||
qCInfo(DlgUpdateLog) << "Opened downloaded update file successfully - closing Cockatrice";
|
qCInfo(DlgUpdateLog) << "Opened downloaded update file successfully - closing Cockatrice";
|
||||||
close();
|
close();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue