mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-16 00:53:58 -05:00
changed RsEvents so that it takes event types when registering handlers, which limits the number of handlers called for each event
This commit is contained in:
parent
dc2f2f5eb4
commit
c544b1da7c
19 changed files with 186 additions and 140 deletions
|
|
@ -45,26 +45,23 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
|||
mEventHandlerId = 0;
|
||||
// Needs to be asynced because this function is likely to be called by another thread!
|
||||
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
rsEvents->registerEventsHandler(RsEventType::GXS_FORUMS, [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
}
|
||||
|
||||
void GxsForumsDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType == RsEventType::GXS_FORUMS)
|
||||
{
|
||||
const RsGxsForumEvent *e = dynamic_cast<const RsGxsForumEvent*>(event.get());
|
||||
const RsGxsForumEvent *e = dynamic_cast<const RsGxsForumEvent*>(event.get());
|
||||
|
||||
if(!e)
|
||||
return;
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
switch(e->mForumEventCode)
|
||||
{
|
||||
case RsGxsForumEvent::ForumEventCode::SUBSCRIBE_STATUS_CHANGED: updateDisplay(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch(e->mForumEventCode)
|
||||
{
|
||||
case RsGxsForumEvent::ForumEventCode::SUBSCRIBE_STATUS_CHANGED: updateDisplay(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GxsForumsDialog::~GxsForumsDialog()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue