From c495ef10b0187a3e7ad37407081f578b5c581835 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Wed, 1 Jul 2020 20:46:49 +0200 Subject: [PATCH] Qt: fix random QWinTaskbarProgress crashes --- rpcs3/rpcs3qt/gs_frame.cpp | 4 +++- rpcs3/rpcs3qt/msg_dialog_frame.cpp | 4 +++- rpcs3/rpcs3qt/progress_dialog.cpp | 7 ++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/rpcs3/rpcs3qt/gs_frame.cpp b/rpcs3/rpcs3qt/gs_frame.cpp index 0fd1c44d5..dfad64572 100644 --- a/rpcs3/rpcs3qt/gs_frame.cpp +++ b/rpcs3/rpcs3qt/gs_frame.cpp @@ -7,6 +7,7 @@ #include "Emu/System.h" #include "Emu/Cell/Modules/cellScreenshot.h" +#include #include #include #include @@ -84,7 +85,8 @@ gs_frame::gs_frame(const QRect& geometry, const QIcon& appIcon, const std::share gs_frame::~gs_frame() { #ifdef _WIN32 - if (m_tb_progress) + // QWinTaskbarProgress::hide() will crash if the application is already about to close, even if the object is not null. + if (m_tb_progress && !QCoreApplication::closingDown()) { m_tb_progress->hide(); } diff --git a/rpcs3/rpcs3qt/msg_dialog_frame.cpp b/rpcs3/rpcs3qt/msg_dialog_frame.cpp index c71a77e91..93d5c9709 100644 --- a/rpcs3/rpcs3qt/msg_dialog_frame.cpp +++ b/rpcs3/rpcs3qt/msg_dialog_frame.cpp @@ -1,6 +1,7 @@ #include "msg_dialog_frame.h" #include "custom_dialog.h" +#include #include #include @@ -173,7 +174,8 @@ msg_dialog_frame::msg_dialog_frame() {} msg_dialog_frame::~msg_dialog_frame() { #ifdef _WIN32 - if (m_tb_progress) + // QWinTaskbarProgress::hide() will crash if the application is already about to close, even if the object is not null. + if (m_tb_progress && !QCoreApplication::closingDown()) { m_tb_progress->hide(); } diff --git a/rpcs3/rpcs3qt/progress_dialog.cpp b/rpcs3/rpcs3qt/progress_dialog.cpp index ba2c5d8c1..482153e43 100644 --- a/rpcs3/rpcs3qt/progress_dialog.cpp +++ b/rpcs3/rpcs3qt/progress_dialog.cpp @@ -1,5 +1,6 @@ #include "progress_dialog.h" +#include #include #ifdef _WIN32 @@ -37,7 +38,11 @@ progress_dialog::progress_dialog(const QString &windowTitle, const QString &labe progress_dialog::~progress_dialog() { #ifdef _WIN32 - m_tb_progress->hide(); + // QWinTaskbarProgress::hide() will crash if the application is already about to close, even if the object is not null. + if (!QCoreApplication::closingDown()) + { + m_tb_progress->hide(); + } #elif HAVE_QTDBUS UpdateProgress(0); #endif