From b4ff1286c79671bd7cf5e6959599fb9eeea03d06 Mon Sep 17 00:00:00 2001 From: pajlada Date: Sat, 23 Nov 2024 15:45:01 +0100 Subject: [PATCH] fix: clear WinToast on exit (#5728) --- CHANGELOG.md | 1 + src/singletons/Toasts.cpp | 7 +++++++ src/singletons/Toasts.hpp | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fea06b0..587e24f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ - Bugfix: Fixed grammar in the user highlight page. (#5602) - Bugfix: Fixed incorrect message being disabled in some cases upon approving or denying an automod caught message. (#5611) - Bugfix: Fixed double-click selection not working when clicking outside a message. (#5617) +- Bugfix: Fixed a potential rare crash that could occur on Windows if a toast was about to fire just as we were shutting down. (#5728) - Bugfix: Fixed emotes starting with ":" not tab-completing. (#5603) - Bugfix: Fixed 7TV emotes messing with Qt's HTML. (#5677) - Bugfix: Fixed incorrect messages getting replaced visually. (#5683) diff --git a/src/singletons/Toasts.cpp b/src/singletons/Toasts.cpp index 7e21dc2c..efcb908b 100644 --- a/src/singletons/Toasts.cpp +++ b/src/singletons/Toasts.cpp @@ -70,6 +70,13 @@ using WinToastLib::WinToast; using WinToastLib::WinToastTemplate; #endif +Toasts::~Toasts() +{ +#ifdef Q_OS_WIN + WinToast::instance()->clear(); +#endif +} + bool Toasts::isEnabled() { #ifdef Q_OS_WIN diff --git a/src/singletons/Toasts.hpp b/src/singletons/Toasts.hpp index e4c2ad23..b57f5c3f 100644 --- a/src/singletons/Toasts.hpp +++ b/src/singletons/Toasts.hpp @@ -3,6 +3,8 @@ #include #include +#include + namespace chatterino { enum class Platform : uint8_t; @@ -17,6 +19,8 @@ enum class ToastReaction { class Toasts final { public: + ~Toasts(); + void sendChannelNotification(const QString &channelName, const QString &channelTitle, Platform p); static QString findStringFromReaction(const ToastReaction &reaction);