fixed 2 other missing postToObject causing GUI calls in async places

This commit is contained in:
csoler 2020-11-15 16:17:44 +01:00
parent aa16be6450
commit 5957a262d3
7 changed files with 18 additions and 21 deletions

View File

@ -38,6 +38,7 @@
#include "util/misc.h" #include "util/misc.h"
#include "util/QtVersion.h" #include "util/QtVersion.h"
#include "util/RsFile.h" #include "util/RsFile.h"
#include "util/qtthreadsutils.h"
#include "retroshare/rsdisc.h" #include "retroshare/rsdisc.h"
#include "retroshare/rsfiles.h" #include "retroshare/rsfiles.h"
@ -1098,12 +1099,11 @@ TransfersDialog::TransfersDialog(QWidget *parent)
registerHelpButton(ui.helpButton,help_str,"TransfersDialog") ; registerHelpButton(ui.helpButton,help_str,"TransfersDialog") ;
mEventHandlerId=0; mEventHandlerId=0;
rsEvents->registerEventsHandler( // Do the GUI events in the GUI thread!
[this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId, RsEventType::FILE_TRANSFER );
mEventHandlerId, RsEventType::FILE_TRANSFER );
} }
void TransfersDialog::handleEvent(std::shared_ptr<const RsEvent> event) void TransfersDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
{ {
if(event->mType != RsEventType::FILE_TRANSFER) return; if(event->mType != RsEventType::FILE_TRANSFER) return;
@ -1115,6 +1115,7 @@ void TransfersDialog::handleEvent(std::shared_ptr<const RsEvent> event)
{ {
case RsFileTransferEventCode::DOWNLOAD_COMPLETE: case RsFileTransferEventCode::DOWNLOAD_COMPLETE:
case RsFileTransferEventCode::COMPLETED_FILES_REMOVED: case RsFileTransferEventCode::COMPLETED_FILES_REMOVED:
getUserNotify()->updateIcon(); getUserNotify()->updateIcon();
default: default:
break; break;

View File

@ -260,7 +260,7 @@ private:
bool controlTransferFile(uint32_t flags); bool controlTransferFile(uint32_t flags);
void changePriority(int priority); void changePriority(int priority);
void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ; void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ;
void handleEvent(std::shared_ptr<const RsEvent> event); void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
QTreeView *downloadList; QTreeView *downloadList;

View File

@ -153,16 +153,10 @@ IdDialog::IdDialog(QWidget *parent) : MainPage(parent), ui(new Ui::IdDialog)
ui->setupUi(this); ui->setupUi(this);
mEventHandlerId_identity = 0; mEventHandlerId_identity = 0;
rsEvents->registerEventsHandler( rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this); }, mEventHandlerId_identity, RsEventType::GXS_IDENTITY );
[this](std::shared_ptr<const RsEvent> event)
{ RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this); },
mEventHandlerId_identity, RsEventType::GXS_IDENTITY );
mEventHandlerId_circles = 0; mEventHandlerId_circles = 0;
rsEvents->registerEventsHandler( rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this); }, mEventHandlerId_circles, RsEventType::GXS_CIRCLES );
[this](std::shared_ptr<const RsEvent> 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. // 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); //mCirclesBroadcastBase = new RsGxsUpdateBroadcastBase(rsGxsCircles, this);

View File

@ -46,6 +46,7 @@
#include "util/DateTime.h" #include "util/DateTime.h"
#include "util/RsProtectedTimer.h" #include "util/RsProtectedTimer.h"
#include "util/QtVersion.h" #include "util/QtVersion.h"
#include "util/qtthreadsutils.h"
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
@ -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&))); connect(ui.messageTreeWidget->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)), this, SLOT(currentChanged(const QModelIndex&,const QModelIndex&)));
mEventHandlerId=0; mEventHandlerId=0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerId, RsEventType::MAIL_STATUS ); rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_STATUS );
} }
void MessagesDialog::handleEvent(std::shared_ptr<const RsEvent> event) void MessagesDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
{ {
if(event->mType != RsEventType::MAIL_STATUS) if(event->mType != RsEventType::MAIL_STATUS)
return; return;

View File

@ -111,7 +111,7 @@ private slots:
void tabCloseRequested(int tab); void tabCloseRequested(int tab);
private: private:
void handleEvent(std::shared_ptr<const RsEvent> event); void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
void updateInterface(); void updateInterface();

View File

@ -55,10 +55,10 @@ HashingStatus::HashingStatus(QWidget *parent)
statusHashing->hide(); statusHashing->hide();
mEventHandlerId=0; mEventHandlerId=0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerId, RsEventType::SHARED_DIRECTORIES ); rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId, RsEventType::SHARED_DIRECTORIES );
} }
void HashingStatus::handleEvent(std::shared_ptr<const RsEvent> event) void HashingStatus::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
{ {
// Warning: no GUI calls should happen here! // Warning: no GUI calls should happen here!
@ -73,7 +73,8 @@ void HashingStatus::handleEvent(std::shared_ptr<const RsEvent> event)
switch (fe->mEventCode) switch (fe->mEventCode)
{ {
case RsSharedDirectoriesEventCode::STARTING_DIRECTORY_SWEEP: default:
case RsSharedDirectoriesEventCode::STARTING_DIRECTORY_SWEEP:
info = tr("Examining shared files..."); info = tr("Examining shared files...");
break; break;
case RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED: case RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED:
@ -88,7 +89,7 @@ void HashingStatus::handleEvent(std::shared_ptr<const RsEvent> event)
// GUI calls should only happen in the GUI thread, which is achieved by postToObject(). // 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() HashingStatus::~HashingStatus()

View File

@ -40,7 +40,7 @@ public:
private: private:
void updateHashingInfo(const QString& s); void updateHashingInfo(const QString& s);
void handleEvent(std::shared_ptr<const RsEvent> event); void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
ElidedLabel *statusHashing; ElidedLabel *statusHashing;
QLabel *hashloader; QLabel *hashloader;