From 554f6136285fc31a54256763ca2f9e84d794ea09 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Thu, 24 Mar 2022 15:27:58 +0200 Subject: [PATCH] Kill timer when dialog is hidden (#1042) IB-7284 Signed-off-by: Raul Metsma --- client/dialogs/WaitDialog.cpp | 11 +++++++---- client/dialogs/WaitDialog_p.h | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/client/dialogs/WaitDialog.cpp b/client/dialogs/WaitDialog.cpp index 1f1faa5e4..aaccf4630 100644 --- a/client/dialogs/WaitDialog.cpp +++ b/client/dialogs/WaitDialog.cpp @@ -26,8 +26,6 @@ #include "Styles.h" #include "effects/Overlay.h" -#include - WaitDialog* WaitDialog::waitDialog = nullptr; WaitDialog::WaitDialog(QWidget *parent) @@ -40,6 +38,8 @@ WaitDialog::WaitDialog(QWidget *parent) ui->movie->load(QStringLiteral(":/images/wait.svg")); ui->label->setFont(Styles::font(Styles::Condensed, 24)); move(parent->geometry().center() - geometry().center()); + timer.setSingleShot(true); + connect(&timer, &QTimer::timeout, this, &WaitDialog::show); } WaitDialog::~WaitDialog() @@ -78,8 +78,8 @@ WaitDialogHolder::WaitDialogHolder(QWidget *parent, const QString &text, bool sh dialog->setText(text); if(show) dialog->show(); - else if(!dialog->isHidden()) - QTimer::singleShot(5000, dialog, &WaitDialog::show); + else + dialog->timer.start(5000); } WaitDialogHolder::~WaitDialogHolder() @@ -92,7 +92,10 @@ WaitDialogHolder::~WaitDialogHolder() WaitDialogHider::WaitDialogHider() { if(WaitDialog *d = WaitDialog::instance()) + { + d->timer.stop(); d->hide(); + } } WaitDialogHider::~WaitDialogHider() diff --git a/client/dialogs/WaitDialog_p.h b/client/dialogs/WaitDialog_p.h index 76e6b5871..f11b740ab 100644 --- a/client/dialogs/WaitDialog_p.h +++ b/client/dialogs/WaitDialog_p.h @@ -20,6 +20,7 @@ #pragma once #include +#include namespace Ui { class WaitDialog; @@ -39,7 +40,7 @@ class WaitDialog : public QDialog static void destroy(); static WaitDialog* instance(); -private: Ui::WaitDialog *ui; static WaitDialog *waitDialog; + QTimer timer; };