diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index 5b0f0c0d4..cc2ef8938 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -38,6 +38,7 @@ #include "util/misc.h" #include "util/QtVersion.h" #include "util/RsFile.h" +#include "util/qtthreadsutils.h" #include "retroshare/rsdisc.h" #include "retroshare/rsfiles.h" @@ -1098,12 +1099,11 @@ TransfersDialog::TransfersDialog(QWidget *parent) registerHelpButton(ui.helpButton,help_str,"TransfersDialog") ; mEventHandlerId=0; - rsEvents->registerEventsHandler( - [this](std::shared_ptr event) { handleEvent(event); }, - mEventHandlerId, RsEventType::FILE_TRANSFER ); + // Do the GUI events in the GUI thread! + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId, RsEventType::FILE_TRANSFER ); } -void TransfersDialog::handleEvent(std::shared_ptr event) +void TransfersDialog::handleEvent_main_thread(std::shared_ptr event) { if(event->mType != RsEventType::FILE_TRANSFER) return; @@ -1115,6 +1115,7 @@ void TransfersDialog::handleEvent(std::shared_ptr event) { case RsFileTransferEventCode::DOWNLOAD_COMPLETE: case RsFileTransferEventCode::COMPLETED_FILES_REMOVED: + getUserNotify()->updateIcon(); default: break; diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h index e11f6c232..87396fc81 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h @@ -260,7 +260,7 @@ private: bool controlTransferFile(uint32_t flags); void changePriority(int priority); void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ; - void handleEvent(std::shared_ptr event); + void handleEvent_main_thread(std::shared_ptr event); QTreeView *downloadList; diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 8ce04d6d2..944fe399b 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -153,16 +153,10 @@ IdDialog::IdDialog(QWidget *parent) : MainPage(parent), ui(new Ui::IdDialog) ui->setupUi(this); mEventHandlerId_identity = 0; - rsEvents->registerEventsHandler( - [this](std::shared_ptr event) - { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this); }, - mEventHandlerId_identity, RsEventType::GXS_IDENTITY ); + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this); }, mEventHandlerId_identity, RsEventType::GXS_IDENTITY ); mEventHandlerId_circles = 0; - rsEvents->registerEventsHandler( - [this](std::shared_ptr event) - { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this); }, - mEventHandlerId_circles, RsEventType::GXS_CIRCLES ); + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this); }, mEventHandlerId_circles, RsEventType::GXS_CIRCLES ); // This is used to grab the broadcast of changes from p3GxsCircles, which is discarded by the current dialog, since it expects data for p3Identity only. //mCirclesBroadcastBase = new RsGxsUpdateBroadcastBase(rsGxsCircles, this); diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 5d6788eb9..0254461f1 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -46,6 +46,7 @@ #include "util/DateTime.h" #include "util/RsProtectedTimer.h" #include "util/QtVersion.h" +#include "util/qtthreadsutils.h" #include #include @@ -286,10 +287,10 @@ MessagesDialog::MessagesDialog(QWidget *parent) connect(ui.messageTreeWidget->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)), this, SLOT(currentChanged(const QModelIndex&,const QModelIndex&))); mEventHandlerId=0; - rsEvents->registerEventsHandler( [this](std::shared_ptr event) { handleEvent(event); }, mEventHandlerId, RsEventType::MAIL_STATUS ); + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_STATUS ); } -void MessagesDialog::handleEvent(std::shared_ptr event) +void MessagesDialog::handleEvent_main_thread(std::shared_ptr event) { if(event->mType != RsEventType::MAIL_STATUS) return; diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.h b/retroshare-gui/src/gui/msgs/MessagesDialog.h index df8513d18..7ecd54865 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.h +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.h @@ -111,7 +111,7 @@ private slots: void tabCloseRequested(int tab); private: - void handleEvent(std::shared_ptr event); + void handleEvent_main_thread(std::shared_ptr event); void updateInterface(); diff --git a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp index 7f65e3902..fc57bb286 100644 --- a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp @@ -55,10 +55,10 @@ HashingStatus::HashingStatus(QWidget *parent) statusHashing->hide(); mEventHandlerId=0; - rsEvents->registerEventsHandler( [this](std::shared_ptr event) { handleEvent(event); }, mEventHandlerId, RsEventType::SHARED_DIRECTORIES ); + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId, RsEventType::SHARED_DIRECTORIES ); } -void HashingStatus::handleEvent(std::shared_ptr event) +void HashingStatus::handleEvent_main_thread(std::shared_ptr event) { // Warning: no GUI calls should happen here! @@ -73,7 +73,8 @@ void HashingStatus::handleEvent(std::shared_ptr event) switch (fe->mEventCode) { - case RsSharedDirectoriesEventCode::STARTING_DIRECTORY_SWEEP: + default: + case RsSharedDirectoriesEventCode::STARTING_DIRECTORY_SWEEP: info = tr("Examining shared files..."); break; case RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED: @@ -88,7 +89,7 @@ void HashingStatus::handleEvent(std::shared_ptr event) // GUI calls should only happen in the GUI thread, which is achieved by postToObject(). - RsQThreadUtils::postToObject( [this,info]() { updateHashingInfo(info); }, this); + updateHashingInfo(info); } HashingStatus::~HashingStatus() diff --git a/retroshare-gui/src/gui/statusbar/hashingstatus.h b/retroshare-gui/src/gui/statusbar/hashingstatus.h index d157e60a0..8f09120a1 100644 --- a/retroshare-gui/src/gui/statusbar/hashingstatus.h +++ b/retroshare-gui/src/gui/statusbar/hashingstatus.h @@ -40,7 +40,7 @@ public: private: void updateHashingInfo(const QString& s); - void handleEvent(std::shared_ptr event); + void handleEvent_main_thread(std::shared_ptr event); ElidedLabel *statusHashing; QLabel *hashloader;