Skip to content

Commit

Permalink
Kill timer when dialog is hidden (open-eid#1042)
Browse files Browse the repository at this point in the history
IB-7284

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored Mar 24, 2022
1 parent 323fd86 commit 554f613
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 7 additions & 4 deletions client/dialogs/WaitDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#include "Styles.h"
#include "effects/Overlay.h"

#include <QTimer>

WaitDialog* WaitDialog::waitDialog = nullptr;

WaitDialog::WaitDialog(QWidget *parent)
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -92,7 +92,10 @@ WaitDialogHolder::~WaitDialogHolder()
WaitDialogHider::WaitDialogHider()
{
if(WaitDialog *d = WaitDialog::instance())
{
d->timer.stop();
d->hide();
}
}

WaitDialogHider::~WaitDialogHider()
Expand Down
3 changes: 2 additions & 1 deletion client/dialogs/WaitDialog_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#pragma once

#include <QDialog>
#include <QTimer>

namespace Ui {
class WaitDialog;
Expand All @@ -39,7 +40,7 @@ class WaitDialog : public QDialog
static void destroy();
static WaitDialog* instance();

private:
Ui::WaitDialog *ui;
static WaitDialog *waitDialog;
QTimer timer;
};

0 comments on commit 554f613

Please sign in to comment.