qt: don't allow PrefsDialog to open multiple times in DialogsProvider

allowing PrefsDialog to be opened multiple time causes massive freezing
This commit is contained in:
Fatih Uzunoglu 2022-03-29 17:14:28 +03:00 committed by Jean-Baptiste Kempf
parent db1abbe031
commit 35a4f48680
1 changed files with 13 additions and 3 deletions

View File

@ -62,6 +62,7 @@
#include <QFileDialog>
#include <QUrl>
#include <QInputDialog>
#include <QPointer>
#define I_OP_DIR_WINTITLE I_DIR_OR_FOLDER( N_("Open Directory"), \
N_("Open Folder") )
@ -248,9 +249,18 @@ const QEvent::Type DialogEvent::DialogEvent_Type =
void DialogsProvider::prefsDialog()
{
PrefsDialog *p = new PrefsDialog( nullptr, p_intf );
p->setAttribute(Qt::WA_DeleteOnClose);
p->toggleVisible();
static QPointer<PrefsDialog> p;
if (Q_LIKELY(!p))
{
p = new PrefsDialog( nullptr, p_intf );
p->setAttribute(Qt::WA_DeleteOnClose);
p->open();
}
else
{
p->reject();
}
}
void DialogsProvider::firstRunDialog()