Skip to content

Commit

Permalink
WIP further changes to prevent crashing on clicking dock icon
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescowens committed Jul 25, 2021
1 parent 8f7bd10 commit d914f2d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions src/qt/upgradeqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ bool UpgradeQt::SnapshotMain(QApplication& SnapshotApp)
return false;
}

Progress = new QProgressDialog("", ToQString(_("Cancel")), 0, 100);
Progress->setWindowModality(Qt::WindowModal);

Progress->setMinimumDuration(0);
Progress->setAutoClose(false);
Progress->setAutoReset(false);
Progress->setValue(0);
Progress->show();

#ifdef Q_OS_MAC
QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);

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

MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
dockIconHandler->setMainWindow((QMainWindow *)this);
dockIconHandler->setMainWindow((QMainWindow *) Progress);
dockIconHandler->setIcon(QPixmap(":/images/gridcoin"));
trayIconMenu = dockIconHandler->dockMenu();
#endif

Progress = new QProgressDialog("", ToQString(_("Cancel")), 0, 100);
Progress->setWindowModality(Qt::WindowModal);

Progress->setMinimumDuration(0);
Progress->setAutoClose(false);
Progress->setAutoReset(false);
Progress->setValue(0);
Progress->show();

#ifdef Q_OS_MAC
connect(dockIconHandler, SIGNAL(dockIconClicked), SLOT(handleDockIconClicked(Progress)));
connect(m_quitAction, SIGNAL(triggered()), this, SLOT(tryQuit(Progress)));
#endif

Expand Down Expand Up @@ -320,6 +319,11 @@ bool UpgradeQt::SnapshotMain(QApplication& SnapshotApp)
return true;
}

void UpgradeQt::handleDockIconClicked(QProgressDialog *Progress)
{
Progress->activateWindow();
}

void UpgradeQt::TryQuit(QProgressDialog *Progress)
{
Progress->cancel();
Expand Down
2 changes: 1 addition & 1 deletion src/qt/upgradeqt.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class UpgradeQt : QObject
QProgressDialog *Progress;

private slots:
void handleDockIconClicked(QProgressDialog *Progress);
void TryQuit(QProgressDialog *Progress);

};
#endif // UPGRADEQT_H

0 comments on commit d914f2d

Please sign in to comment.