Merge pull request #4558

80e209d filter: intercept quit event to avoid deadlock (selsta)
This commit is contained in:
tobtoht
2026-01-29 15:40:40 +00:00
4 changed files with 17 additions and 0 deletions

View File

@@ -100,6 +100,7 @@ ApplicationWindow {
property bool splashDisplayedBeforeButtonRequest;
property bool themeTransition: false
property int backgroundSyncType: Wallet.BackgroundSync_Off;
property bool isQuitting: false
// fiat price conversion
property real fiatPrice: 0
@@ -282,6 +283,15 @@ ApplicationWindow {
persistentSettings.kdfRounds);
}
function gracefulQuit() {
if (isQuitting)
return;
isQuitting = true;
closeWallet(function() {
Qt.quit();
})
}
function closeWallet(callback) {
// Disconnect all listeners

View File

@@ -38,6 +38,11 @@ filter::filter(QObject *parent) :
}
bool filter::eventFilter(QObject *obj, QEvent *ev) {
if (ev->type() == QEvent::Quit) {
emit quitRequested();
return true;
}
// macOS sends fileopen signal for incoming uri handlers
if (ev->type() == QEvent::FileOpen) {
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(ev);

View File

@@ -44,6 +44,7 @@ protected:
bool eventFilter(QObject *obj, QEvent *ev);
signals:
void quitRequested();
void sequencePressed(const QVariant &o, const QVariant &seq);
void sequenceReleased(const QVariant &o, const QVariant &seq);
void mousePressed(const QVariant &o, const QVariant &x, const QVariant &y);

View File

@@ -562,6 +562,7 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
qCritical() << "QrCodeScanner : something went wrong !";
#endif
QObject::connect(eventFilter, &filter::quitRequested, rootObject, [rootObject]{ QMetaObject::invokeMethod(rootObject, "gracefulQuit", Qt::QueuedConnection); });
QObject::connect(eventFilter, SIGNAL(sequencePressed(QVariant,QVariant)), rootObject, SLOT(sequencePressed(QVariant,QVariant)));
QObject::connect(eventFilter, SIGNAL(sequenceReleased(QVariant,QVariant)), rootObject, SLOT(sequenceReleased(QVariant,QVariant)));
QObject::connect(eventFilter, SIGNAL(mousePressed(QVariant,QVariant,QVariant)), rootObject, SLOT(mousePressed(QVariant,QVariant,QVariant)));