fix: improve error messaging when pgrep fails streamer mode detection (#5321)

When launching pgrep times out, a timeout message is now posted instead of the default "pgrep is not installed" error.
This commit is contained in:
pajlada
2024-04-13 09:01:20 +02:00
committed by GitHub
parent f4e950ea0b
commit bf8266e9b3
2 changed files with 40 additions and 10 deletions
+1
View File
@@ -4,6 +4,7 @@
- Minor: Added context menu action to toggle visibility of offline tabs. (#5318) - Minor: Added context menu action to toggle visibility of offline tabs. (#5318)
- Minor: Report sub duration for more multi-month gift cases. (#5319) - Minor: Report sub duration for more multi-month gift cases. (#5319)
- Minor: Improved error reporting for the automatic streamer mode detection on Linux and macOS. (#5321)
- Bugfix: Fixed a crash that could occur on Wayland when using the image uploader. (#5314) - Bugfix: Fixed a crash that could occur on Wayland when using the image uploader. (#5314)
- Bugfix: Fixed split tooltip getting stuck in some cases. (#5309) - Bugfix: Fixed split tooltip getting stuck in some cases. (#5309)
- Bugfix: Fixed the version string not showing up as expected in Finder on macOS. (#5311) - Bugfix: Fixed the version string not showing up as expected in Finder on macOS. (#5311)
+32 -3
View File
@@ -51,6 +51,9 @@ const QStringList &broadcastingBinaries()
bool isBroadcasterSoftwareActive() bool isBroadcasterSoftwareActive()
{ {
#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS) #if defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
static bool shouldShowTimeoutWarning = true;
static bool shouldShowWarning = true;
QProcess p; QProcess p;
p.start("pgrep", {"-xi", broadcastingBinaries().join("|")}, p.start("pgrep", {"-xi", broadcastingBinaries().join("|")},
QIODevice::NotOpen); QIODevice::NotOpen);
@@ -62,20 +65,46 @@ bool isBroadcasterSoftwareActive()
// Fallback to false and showing a warning // Fallback to false and showing a warning
static bool shouldShowWarning = true; switch (p.error())
{
case QProcess::Timedout: {
qCWarning(chatterinoStreamerMode) << "pgrep execution timed out!";
if (shouldShowTimeoutWarning)
{
shouldShowTimeoutWarning = false;
postToThread([] {
getApp()->twitch->addGlobalSystemMessage(
"Streamer Mode is set to Automatic, but pgrep timed "
"out. This can happen if your system lagged at the "
"wrong moment. If Streamer Mode continues to not work, "
"you can manually set it to Enabled or Disabled in the "
"Settings.");
});
}
}
break;
default: {
qCWarning(chatterinoStreamerMode)
<< "pgrep execution failed:" << p.error();
if (shouldShowWarning) if (shouldShowWarning)
{ {
shouldShowWarning = false; shouldShowWarning = false;
postToThread([] { postToThread([] {
getApp()->twitch->addGlobalSystemMessage( getApp()->twitch->addGlobalSystemMessage(
"Streamer Mode is set to Automatic, but pgrep is missing. " "Streamer Mode is set to Automatic, but pgrep is "
"missing. "
"Install it to fix the issue or set Streamer Mode to " "Install it to fix the issue or set Streamer Mode to "
"Enabled or Disabled in the Settings."); "Enabled or Disabled in the Settings.");
}); });
} }
}
break;
}
qCWarning(chatterinoStreamerMode) << "pgrep execution timed out!";
return false; return false;
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
if (!IsWindowsVistaOrGreater()) if (!IsWindowsVistaOrGreater())