diff --git a/CHANGELOG.md b/CHANGELOG.md index b971a6597..8b602b1c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - Bugfix: Fixed own IRC messages not having metadata and a link to a usercard. (#3203) - Bugfix: Fixed some channels still not loading in rare cases. (#3219) - Bugfix: Fixed a bug with usernames or emotes completing from the wrong position. (#3229) +- Bugfix: Fixed second chatterino icon appearing in the dock when restarting on a crash in macOS. (#3268) - Dev: Renamed CMake's build option `USE_SYSTEM_QT5KEYCHAIN` to `USE_SYSTEM_QTKEYCHAIN`. (#3103) - Dev: Add benchmarks that can be compiled with the `BUILD_BENCHMARKS` CMake flag. Off by default. (#3038) diff --git a/src/RunGui.cpp b/src/RunGui.cpp index 998c726b6..cd7f3e116 100644 --- a/src/RunGui.cpp +++ b/src/RunGui.cpp @@ -28,6 +28,10 @@ # include #endif +#ifdef Q_OS_MAC +# include "corefoundation/CFBundle.h" +#endif + namespace chatterino { namespace { void installCustomPalette() @@ -122,8 +126,29 @@ namespace { std::chrono::steady_clock::now() - signalsInitTime > 30s) { QProcess proc; + +#ifdef Q_OS_MAC + // On macOS, programs are bundled into ".app" Application bundles, + // when restarting chatterino that bundle should be opened with the "open" + // terminal command instead of directly starting the underlying executable, + // as those are 2 different things for the OS and i.e. do not use + // the same dock icon (resulting in a second chatterino icon on restarting) + CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); + CFStringRef macPath = + CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle); + const char *pathPtr = + CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding()); + + proc.setProgram("open"); + proc.setArguments({pathPtr, "--args", "--crash-recovery"}); + + CFRelease(appUrlRef); + CFRelease(macPath); +#else proc.setProgram(QApplication::applicationFilePath()); proc.setArguments({"--crash-recovery"}); +#endif + proc.startDetached(); }