fix: better handle Windows shutting down in newer Qt versions (#6368)

This commit is contained in:
pajlada
2025-08-09 11:43:32 +02:00
committed by GitHub
parent f21f1b8781
commit f7042dc542
5 changed files with 20 additions and 5 deletions
+2
View File
@@ -607,6 +607,8 @@ void Application::aboutToQuit()
this->hotkeys->save();
this->windows->save();
this->windows->closeAll();
}
void Application::stop()
+1 -1
View File
@@ -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++)
{
+4 -1
View File
@@ -5,6 +5,7 @@
#include "widgets/splits/SplitContainer.hpp"
#include <pajlada/settings/settinglistener.hpp>
#include <QObject>
#include <QPoint>
#include <QTimer>
@@ -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;
+12 -3
View File
@@ -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();