Qt: fix random QWinTaskbarProgress crashes

This commit is contained in:
Megamouse 2020-07-01 20:46:49 +02:00
parent 3bdce6050b
commit c495ef10b0
3 changed files with 12 additions and 3 deletions

View File

@ -7,6 +7,7 @@
#include "Emu/System.h"
#include "Emu/Cell/Modules/cellScreenshot.h"
#include <QCoreApplication>
#include <QKeyEvent>
#include <QMessageBox>
#include <string>
@ -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();
}

View File

@ -1,6 +1,7 @@
#include "msg_dialog_frame.h"
#include "custom_dialog.h"
#include <QCoreApplication>
#include <QPushButton>
#include <QFormLayout>
@ -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();
}

View File

@ -1,5 +1,6 @@
#include "progress_dialog.h"
#include <QCoreApplication>
#include <QLabel>
#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