From 3f21b4bf65ee684d0b801348cb43465cae499606 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 28 Sep 2025 13:10:09 +0200 Subject: [PATCH] fixed bug causing passwd request to fail --- retroshare-gui/src/gui/notifyqt.cpp | 33 ++++++++++++++++++----------- retroshare-gui/src/gui/notifyqt.h | 6 ++++-- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 26d6f3890..c1d9b441e 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -110,7 +110,13 @@ NotifyQt::NotifyQt() : cDialog(NULL) // Catch all events that require toasters and mEventHandlerId = 0; - rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ handleIncomingEvent(event); }, this ); }, mEventHandlerId); // No event type means we expect to catch all possible events + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + if(event->mType == RsEventType::SYSTEM_ERROR && dynamic_cast(event.get())->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED) + sync_handleIncomingEvent(event); + else + RsQThreadUtils::postToObject([=](){ async_handleIncomingEvent(event); }, this ); + }, mEventHandlerId); // No event type means we expect to catch all possible events #ifdef TO_REMOVE // register to allow sending over Qt::QueuedConnection @@ -270,7 +276,7 @@ bool NotifyQt::graphical_askForPassword(const std::string& title, const std::str RsAutoUpdatePage::unlockAllEvents() ; - if (ret.execReturn == QDialog::Rejected) { + if (ret.execReturn == QDialog::Rejected) { RsLoginHelper::clearPgpPassphrase(); password.clear() ; cancelled = true ; @@ -683,7 +689,19 @@ void NotifyQt::enable() _enabled = true ; } -void NotifyQt::handleIncomingEvent(std::shared_ptr event) +void NotifyQt::sync_handleIncomingEvent(std::shared_ptr event) +{ + auto ev6 = dynamic_cast(event.get()); + + if(ev6->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED) + { + std::string password; + bool cancelled; + graphical_askForPassword(ev6->passwd_request_title, ev6->passwd_request_key_details, ev6->passwd_request_prev_is_bad, password,cancelled); + } +} + +void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) { static bool already_updated = false ; // these only update once at start because they may already have been set before // the gui is running, then they get updated by callbacks. @@ -854,15 +872,6 @@ void NotifyQt::handleIncomingEvent(std::shared_ptr event) case RsSystemEventCode::GENERAL_ERROR: displayErrorMessage(RS_SYS_WARNING,tr("Internal error"),QString::fromUtf8(ev6->mErrorMsg.c_str())); break; - - case RsSystemEventCode::PASSWORD_REQUESTED: - { - std::string password; - bool cancelled; - graphical_askForPassword(ev6->passwd_request_title, ev6->passwd_request_key_details, ev6->passwd_request_prev_is_bad, password,cancelled); - break; - } - default: break; } return; diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 4843c55dc..a669864c6 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -146,7 +146,7 @@ class NotifyQt: public QObject, public NotifyClient private slots: void runningTick(); - void handleSignatureEvent() ; + void handleSignatureEvent() ; // void handleChatLobbyTimeShift(int) ; private: @@ -176,7 +176,9 @@ class NotifyQt: public QObject, public NotifyClient /* so we can update windows */ NetworkDialog *cDialog; - void handleIncomingEvent(std::shared_ptr e); /* called by timer */ + void async_handleIncomingEvent(std::shared_ptr e); + void sync_handleIncomingEvent(std::shared_ptr e); + RsEventsHandlerId_t mEventHandlerId; };