Skip to content

Commit d914f2d

Browse files
committed
WIP further changes to prevent crashing on clicking dock icon
1 parent 8f7bd10 commit d914f2d

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/qt/upgradeqt.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ bool UpgradeQt::SnapshotMain(QApplication& SnapshotApp)
4949
return false;
5050
}
5151

52+
Progress = new QProgressDialog("", ToQString(_("Cancel")), 0, 100);
53+
Progress->setWindowModality(Qt::WindowModal);
54+
55+
Progress->setMinimumDuration(0);
56+
Progress->setAutoClose(false);
57+
Progress->setAutoReset(false);
58+
Progress->setValue(0);
59+
Progress->show();
60+
5261
#ifdef Q_OS_MAC
5362
QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
5463

@@ -62,21 +71,11 @@ bool UpgradeQt::SnapshotMain(QApplication& SnapshotApp)
6271
file->addAction(m_quitAction);
6372

6473
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
65-
dockIconHandler->setMainWindow((QMainWindow *)this);
74+
dockIconHandler->setMainWindow((QMainWindow *) Progress);
6675
dockIconHandler->setIcon(QPixmap(":/images/gridcoin"));
6776
trayIconMenu = dockIconHandler->dockMenu();
68-
#endif
6977

70-
Progress = new QProgressDialog("", ToQString(_("Cancel")), 0, 100);
71-
Progress->setWindowModality(Qt::WindowModal);
72-
73-
Progress->setMinimumDuration(0);
74-
Progress->setAutoClose(false);
75-
Progress->setAutoReset(false);
76-
Progress->setValue(0);
77-
Progress->show();
78-
79-
#ifdef Q_OS_MAC
78+
connect(dockIconHandler, SIGNAL(dockIconClicked), SLOT(handleDockIconClicked(Progress)));
8079
connect(m_quitAction, SIGNAL(triggered()), this, SLOT(tryQuit(Progress)));
8180
#endif
8281

@@ -320,6 +319,11 @@ bool UpgradeQt::SnapshotMain(QApplication& SnapshotApp)
320319
return true;
321320
}
322321

322+
void UpgradeQt::handleDockIconClicked(QProgressDialog *Progress)
323+
{
324+
Progress->activateWindow();
325+
}
326+
323327
void UpgradeQt::TryQuit(QProgressDialog *Progress)
324328
{
325329
Progress->cancel();

src/qt/upgradeqt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ class UpgradeQt : QObject
8383
QProgressDialog *Progress;
8484

8585
private slots:
86+
void handleDockIconClicked(QProgressDialog *Progress);
8687
void TryQuit(QProgressDialog *Progress);
87-
8888
};
8989
#endif // UPGRADEQT_H
9090

0 commit comments

Comments
 (0)