mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-31 10:19:24 -04:00
Fix JSON API event handler registering behavior
As a bonus the behaviour is now homogeneous between C++ API and JSON API Fix a bunch of compiler warning RsEvents implementation is now safer mHandlerMaps size is known at compile time, so use an std::array instead of vector
This commit is contained in:
parent
ce5f5faa97
commit
4c0baa1ec3
17 changed files with 165 additions and 139 deletions
|
@ -47,12 +47,14 @@
|
|||
// };
|
||||
|
||||
/** Constructor */
|
||||
GxsChannelDialog::GxsChannelDialog(QWidget *parent)
|
||||
: GxsGroupFrameDialog(rsGxsChannels, parent,true)
|
||||
GxsChannelDialog::GxsChannelDialog(QWidget *parent):
|
||||
GxsGroupFrameDialog(rsGxsChannels, parent, true), mEventHandlerId(0)
|
||||
{
|
||||
mEventHandlerId = 0;
|
||||
// Needs to be asynced because this function is likely to be called by another thread!
|
||||
rsEvents->registerEventsHandler(RsEventType::GXS_CHANNELS, [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
// Needs to be asynced because this function is called by another thread!
|
||||
rsEvents->registerEventsHandler(
|
||||
[this](std::shared_ptr<const RsEvent> event)
|
||||
{ RsQThreadUtils::postToObject([=]() { handleEvent_main_thread(event); }, this ); },
|
||||
mEventHandlerId, RsEventType::GXS_CHANNELS );
|
||||
}
|
||||
|
||||
void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
|
|
|
@ -130,9 +130,11 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
|
|||
setGroupId(channelId);
|
||||
|
||||
mEventHandlerId = 0;
|
||||
// Needs to be asynced because this function is likely to be called by another thread!
|
||||
|
||||
rsEvents->registerEventsHandler(RsEventType::GXS_CHANNELS, [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
// Needs to be asynced because this function is called by another thread!
|
||||
rsEvents->registerEventsHandler(
|
||||
[this](std::shared_ptr<const RsEvent> event)
|
||||
{ RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this ); },
|
||||
mEventHandlerId, RsEventType::GXS_CHANNELS );
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue