mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
fixed bug caused by calling GUI out of main GUI thread
This commit is contained in:
parent
f9bb886c27
commit
aa16be6450
1 changed files with 7 additions and 4 deletions
|
@ -26,6 +26,7 @@
|
||||||
#include "retroshare/rsfiles.h"
|
#include "retroshare/rsfiles.h"
|
||||||
#include "hashingstatus.h"
|
#include "hashingstatus.h"
|
||||||
#include "gui/common/ElidedLabel.h"
|
#include "gui/common/ElidedLabel.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
#include "gui/notifyqt.h"
|
#include "gui/notifyqt.h"
|
||||||
#include "gui/common/FilesDefs.h"
|
#include "gui/common/FilesDefs.h"
|
||||||
|
|
||||||
|
@ -54,13 +55,13 @@ HashingStatus::HashingStatus(QWidget *parent)
|
||||||
statusHashing->hide();
|
statusHashing->hide();
|
||||||
|
|
||||||
mEventHandlerId=0;
|
mEventHandlerId=0;
|
||||||
rsEvents->registerEventsHandler(
|
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerId, RsEventType::SHARED_DIRECTORIES );
|
||||||
[this](std::shared_ptr<const RsEvent> event) { handleEvent(event); },
|
|
||||||
mEventHandlerId, RsEventType::SHARED_DIRECTORIES );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HashingStatus::handleEvent(std::shared_ptr<const RsEvent> event)
|
void HashingStatus::handleEvent(std::shared_ptr<const RsEvent> event)
|
||||||
{
|
{
|
||||||
|
// Warning: no GUI calls should happen here!
|
||||||
|
|
||||||
if(event->mType != RsEventType::SHARED_DIRECTORIES)
|
if(event->mType != RsEventType::SHARED_DIRECTORIES)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -85,7 +86,9 @@ void HashingStatus::handleEvent(std::shared_ptr<const RsEvent> event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHashingInfo(info);
|
// GUI calls should only happen in the GUI thread, which is achieved by postToObject().
|
||||||
|
|
||||||
|
RsQThreadUtils::postToObject( [this,info]() { updateHashingInfo(info); }, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashingStatus::~HashingStatus()
|
HashingStatus::~HashingStatus()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue