mirror of
https://github.com/RetroShare/RetroShare.git
synced 2026-09-13 18:46:04 +05:00
extended event throttling to Channels, Forums, Boards, and Circles to prevent UI freezes
This commit is contained in:
parent
216d25086b
commit
461d21d6c4
@ -451,6 +451,9 @@ IdDialog::IdDialog(QWidget *parent)
|
||||
updateIdTimer.setSingleShot(true);
|
||||
connect(&updateIdTimer, SIGNAL(timeout()), this, SLOT(updateIdList()));
|
||||
|
||||
updateCirclesTimer.setSingleShot(true);
|
||||
connect(&updateCirclesTimer, SIGNAL(timeout()), this, SLOT(updateCircles()));
|
||||
|
||||
mFontSizeHandler.registerFontSize(ui->idTreeWidget, 0, [this] (QAbstractItemView*, int fontSize) {
|
||||
// Set new font size on all items
|
||||
mIdListModel->setFontSize(fontSize);
|
||||
@ -540,7 +543,10 @@ void IdDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
case RsGxsCircleEventCode::CACHE_DATA_UPDATED:
|
||||
|
||||
if (isVisible())
|
||||
updateCircles();
|
||||
{
|
||||
if(!updateCirclesTimer.isActive())
|
||||
updateCirclesTimer.start(200);
|
||||
}
|
||||
else
|
||||
needUpdateCirclesOnNextShow = true;
|
||||
default:
|
||||
@ -1426,13 +1432,11 @@ void IdDialog::updateIdListRequest()
|
||||
{
|
||||
if(updateIdTimer.isActive())
|
||||
{
|
||||
std::cerr << "updateIdListRequest(): restarting timer"<< std::endl;
|
||||
updateIdTimer.stop();
|
||||
updateIdTimer.start(1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "updateIdListRequest(): starting timer"<< std::endl;
|
||||
updateIdTimer.start(1000);
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,6 +181,7 @@ private:
|
||||
RsEventsHandlerId_t mEventHandlerId_circles;
|
||||
|
||||
QTimer updateIdTimer;
|
||||
QTimer updateCirclesTimer;
|
||||
bool needUpdateIdsOnNextShow;
|
||||
bool needUpdateCirclesOnNextShow;
|
||||
|
||||
|
||||
@ -51,6 +51,9 @@ PostedDialog::PostedDialog(QWidget *parent):
|
||||
[this](std::shared_ptr<const RsEvent> event)
|
||||
{ RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); },
|
||||
mEventHandlerId, RsEventType::GXS_POSTED );
|
||||
mUpdateTimer = new QTimer(this);
|
||||
mUpdateTimer->setSingleShot(true);
|
||||
connect(mUpdateTimer, SIGNAL(timeout()), this, SLOT(timerUpdate()));
|
||||
}
|
||||
|
||||
void PostedDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
@ -72,10 +75,11 @@ void PostedDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
case RsPostedEventCode::NEW_POSTED_GROUP: // [[fallthrough]];
|
||||
case RsPostedEventCode::BOARD_DELETED: // [[fallthrough]];
|
||||
case RsPostedEventCode::SUBSCRIBE_STATUS_CHANGED: // [[fallthrough]];
|
||||
updateDisplay(true);
|
||||
if(!mUpdateTimer->isActive()) mUpdateTimer->start(200);
|
||||
break;
|
||||
|
||||
case RsPostedEventCode::STATISTICS_CHANGED:
|
||||
if(!mUpdateTimer->isActive()) mUpdateTimer->start(200);
|
||||
updateGroupStatistics(e->mPostedGroupId);
|
||||
break;
|
||||
|
||||
|
||||
@ -65,6 +65,11 @@ private:
|
||||
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
|
||||
QTimer *mUpdateTimer;
|
||||
|
||||
private slots:
|
||||
void timerUpdate() { updateDisplay(true); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -57,6 +57,9 @@ GxsChannelDialog::GxsChannelDialog(QWidget *parent):
|
||||
[this](std::shared_ptr<const RsEvent> event)
|
||||
{ RsQThreadUtils::postToObject([=]() { handleEvent_main_thread(event); }, this ); },
|
||||
mEventHandlerId, RsEventType::GXS_CHANNELS );
|
||||
mUpdateTimer = new QTimer(this);
|
||||
mUpdateTimer->setSingleShot(true);
|
||||
connect(mUpdateTimer, SIGNAL(timeout()), this, SLOT(timerUpdate()));
|
||||
}
|
||||
|
||||
void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
@ -67,7 +70,7 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> ev
|
||||
switch(e->mChannelEventCode)
|
||||
{
|
||||
case RsChannelEventCode::STATISTICS_CHANGED: // [[fallthrough]];
|
||||
updateDisplay(true); // no breaks, on purpose!
|
||||
if(!mUpdateTimer->isActive()) mUpdateTimer->start(200);
|
||||
Q_FALLTHROUGH();
|
||||
|
||||
case RsChannelEventCode::NEW_MESSAGE: // [[fallthrough]];
|
||||
@ -82,7 +85,7 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> ev
|
||||
case RsChannelEventCode::NEW_CHANNEL: // [[fallthrough]];
|
||||
case RsChannelEventCode::DELETED_CHANNEL: // [[fallthrough]];
|
||||
case RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED:// reloads group summary (calling GxsGroupFrameDialog parent method)
|
||||
updateDisplay(true);
|
||||
if(!mUpdateTimer->isActive()) mUpdateTimer->start(200);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@ -86,6 +86,11 @@ private:
|
||||
std::set<TurtleRequestId> mSearchResults;
|
||||
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
|
||||
QTimer *mUpdateTimer;
|
||||
|
||||
private slots:
|
||||
void timerUpdate() { updateDisplay(true); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -47,6 +47,9 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent) :
|
||||
[this](std::shared_ptr<const RsEvent> event)
|
||||
{ RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); },
|
||||
mEventHandlerId, RsEventType::GXS_FORUMS );
|
||||
mUpdateTimer = new QTimer(this);
|
||||
mUpdateTimer->setSingleShot(true);
|
||||
connect(mUpdateTimer, SIGNAL(timeout()), this, SLOT(timerUpdate()));
|
||||
}
|
||||
|
||||
void GxsForumsDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
@ -70,11 +73,11 @@ void GxsForumsDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> eve
|
||||
case RsForumEventCode::UPDATED_FORUM: // [[fallthrough]];
|
||||
case RsForumEventCode::DELETED_FORUM: // [[fallthrough]];
|
||||
case RsForumEventCode::SUBSCRIBE_STATUS_CHANGED:
|
||||
updateDisplay(true);
|
||||
if(!mUpdateTimer->isActive()) mUpdateTimer->start(200);
|
||||
break;
|
||||
|
||||
case RsForumEventCode::STATISTICS_CHANGED:
|
||||
updateDisplay(true);
|
||||
if(!mUpdateTimer->isActive()) mUpdateTimer->start(200);
|
||||
updateGroupStatisticsReal(e->mForumGroupId);
|
||||
break;
|
||||
|
||||
|
||||
@ -65,6 +65,11 @@ private:
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
|
||||
QTimer *mUpdateTimer;
|
||||
|
||||
private slots:
|
||||
void timerUpdate() { updateDisplay(true); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user