From b7dd32274ca3b04b66ed76f6bb68b77ab5acb338 Mon Sep 17 00:00:00 2001 From: Rachel Powers <508861+Ryex@users.noreply.github.com> Date: Sun, 25 Jun 2023 22:30:20 -0700 Subject: [PATCH] Proper capture on windows Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> --- launcher/Application.cpp | 2 -- launcher/StringUtils.cpp | 6 +++--- launcher/updater/PrismExternalUpdater.cpp | 15 ++++++++++++++- launcher/updater/prismupdater/PrismUpdater.cpp | 6 +----- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index a5103e8e5..4c88a950d 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -280,8 +280,6 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) BindCrtHandlesToStdHandles(true, true, true); consoleAttached = true; } - } else if (stdout_type == FILE_TYPE_DISK || stdout_type == FILE_TYPE_PIPE ) { - BindCrtHandlesToStdHandles(true, true, true); } #endif setOrganizationName(BuildConfig.LAUNCHER_NAME); diff --git a/launcher/StringUtils.cpp b/launcher/StringUtils.cpp index f437b6dac..b54299721 100644 --- a/launcher/StringUtils.cpp +++ b/launcher/StringUtils.cpp @@ -184,7 +184,7 @@ QString StringUtils::getRandomAlphaNumeric() return QUuid::createUuid().toString(QUuid::Id128); } -QPair splitFirst(const QString& s, const QString& sep, Qt::CaseSensitivity cs = Qt::CaseSensitive) { +QPair StringUtils::splitFirst(const QString& s, const QString& sep, Qt::CaseSensitivity cs) { QString left, right; auto index = s.indexOf(sep, 0, cs); left = s.mid(0, index); @@ -192,7 +192,7 @@ QPair splitFirst(const QString& s, const QString& sep, Qt::Cas return qMakePair(left, right); } -QPair splitFirst(const QString& s, QChar sep, Qt::CaseSensitivity cs = Qt::CaseSensitive) { +QPair StringUtils::splitFirst(const QString& s, QChar sep, Qt::CaseSensitivity cs) { QString left, right; auto index = s.indexOf(sep, 0, cs); left = s.mid(0, index); @@ -200,7 +200,7 @@ QPair splitFirst(const QString& s, QChar sep, Qt::CaseSensitiv return qMakePair(left, right); } -QPair splitFirst(const QString& s, const QRegularExpression& re) { +QPair StringUtils::splitFirst(const QString& s, const QRegularExpression& re) { QString left, right; auto index = s.indexOf(re); left = s.mid(0, index); diff --git a/launcher/updater/PrismExternalUpdater.cpp b/launcher/updater/PrismExternalUpdater.cpp index f510dfc6c..9ec033f02 100644 --- a/launcher/updater/PrismExternalUpdater.cpp +++ b/launcher/updater/PrismExternalUpdater.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "StringUtils.h" @@ -80,6 +81,8 @@ void PrismExternalUpdater::checkForUpdates() QProgressDialog progress(tr("Checking for updates..."), "", 0, -1); progress.setCancelButton(nullptr); progress.show(); + QCoreApplication::processEvents(); + QProcess proc; auto exe_name = QStringLiteral("%1_updater").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME); @@ -87,7 +90,7 @@ void PrismExternalUpdater::checkForUpdates() exe_name.append(".exe"); #endif - QStringList args = { "--check-only" }; + QStringList args = { "--check-only", "--dir", priv->dataDir.absolutePath(), "--debug" }; if (priv->allowBeta) args.append("--pre-release"); @@ -97,6 +100,8 @@ void PrismExternalUpdater::checkForUpdates() auto err = proc.error(); qDebug() << "Failed to start updater after 5 seconds." << "reason:" << err << proc.errorString(); } + QCoreApplication::processEvents(); + auto result_finished = proc.waitForFinished(60000); if (!result_finished) { auto err = proc.error(); @@ -108,6 +113,9 @@ void PrismExternalUpdater::checkForUpdates() auto std_output = proc.readAllStandardOutput(); auto std_error = proc.readAllStandardError(); + qDebug() << "captured output:" << std_output; + qDebug() << "captured error:" << std_error; + switch (exit_code) { case 0: // no update available @@ -188,6 +196,7 @@ void PrismExternalUpdater::resetAutoCheckTimer() { secs_left = 0; timeoutDuration = secs_left * 1000; // to msec } + qDebug() << "Auto update timer starting," << timeoutDuration / 1000 << "seconds left"; priv->updateTimer.start(timeoutDuration); } else { if (priv->updateTimer.isActive()) @@ -204,3 +213,7 @@ void PrismExternalUpdater::connectTimer() { void PrismExternalUpdater::disconnectTimer() { disconnect(&priv->updateTimer, &QTimer::timeout, this, &PrismExternalUpdater::autoCheckTimerFired); } + +void PrismExternalUpdater::autoCheckTimerFired() { + checkForUpdates(); +} diff --git a/launcher/updater/prismupdater/PrismUpdater.cpp b/launcher/updater/prismupdater/PrismUpdater.cpp index f04a12c94..e01295605 100644 --- a/launcher/updater/prismupdater/PrismUpdater.cpp +++ b/launcher/updater/prismupdater/PrismUpdater.cpp @@ -41,7 +41,6 @@ #include #include -#include #if defined Q_OS_WIN32 #ifndef WIN32_LEAN_AND_MEAN @@ -210,10 +209,7 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar BindCrtHandlesToStdHandles(true, true, true); consoleAttached = true; } - } else if (stdout_type == FILE_TYPE_DISK || stdout_type == FILE_TYPE_PIPE ) { - BindCrtHandlesToStdHandles(true, true, true); - } - + } #endif setOrganizationName(BuildConfig.LAUNCHER_NAME); setOrganizationDomain(BuildConfig.LAUNCHER_DOMAIN);