diff --git a/CHANGELOG.md b/CHANGELOG.md index 622bddbe..7eab057c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ - Bugfix: Fixed a crash that could occur an eventsub connection's keepalive timer would run after the connection was dead, causing the keepalive timer to use-itself-after-free. (#6204) - Bugfix: Fixed a crash that could occur when an image started loading mid app shutdown. (#6213) - Bugfix: Fixed a crash that could occur on exit if a ping played less than 30 seconds prior. (#6332) +- Bugfix: Fixed a crash that could occur on exit on newer versions of Qt. (#6368) - Bugfix: Fixed notebook buttons (settings, account switcher, streamer mode) not performing a relayout when their visibility changed, causing a gap until resize. Linux / macOS only. (#6328) - Bugfix: Fixed some minor typos. (#6196) - Bugfix: Fixed inconsistent spaces in messages when using fractional scaling. (#6231, #6254) diff --git a/src/Application.cpp b/src/Application.cpp index beca437f..5e078dec 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -607,6 +607,8 @@ void Application::aboutToQuit() this->hotkeys->save(); this->windows->save(); + + this->windows->closeAll(); } void Application::stop() diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index 94b9f66e..e2a7cdd5 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -350,7 +350,7 @@ Window &WindowManager::createWindow(WindowType type, bool show, QWidget *parent) { window->setAttribute(Qt::WA_DeleteOnClose); - QObject::connect(window, &QWidget::destroyed, [this, window] { + QObject::connect(window, &QWidget::destroyed, this, [this, window] { for (auto it = this->windows_.begin(); it != this->windows_.end(); it++) { diff --git a/src/singletons/WindowManager.hpp b/src/singletons/WindowManager.hpp index 066cf5d1..49c0f91c 100644 --- a/src/singletons/WindowManager.hpp +++ b/src/singletons/WindowManager.hpp @@ -5,6 +5,7 @@ #include "widgets/splits/SplitContainer.hpp" #include +#include #include #include @@ -36,8 +37,10 @@ enum class WindowType; enum class SettingsDialogPreference; class FramelessEmbedWindow; -class WindowManager final +class WindowManager final : public QObject { + Q_OBJECT + Theme &themes; const Args &appArgs; diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 047b8cd0..04d7c9db 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -153,10 +153,19 @@ bool Window::event(QEvent *event) void Window::closeEvent(QCloseEvent *) { + if (isAppAboutToQuit()) + { + qCWarning(chatterinoWidget) + << "Window closeEvent ran when Application is already dead"; + return; + } + + auto *app = getApp(); + if (this->type_ == WindowType::Main) { - getApp()->getWindows()->save(); - getApp()->getWindows()->closeAll(); + app->getWindows()->save(); + app->getWindows()->closeAll(); } else { @@ -167,7 +176,7 @@ void Window::closeEvent(QCloseEvent *) // Ensure selectedWindow_ is never an invalid pointer. // WindowManager will return the main window if no window is pointed to by // `selectedWindow_`. - getApp()->getWindows()->selectedWindow_ = nullptr; + app->getWindows()->selectedWindow_ = nullptr; this->closed.invoke();