From dfa9e39612a003e8d588dc7367d469b5db1c0481 Mon Sep 17 00:00:00 2001 From: jolavillette Date: Tue, 16 Dec 2025 04:42:01 +0100 Subject: [PATCH] Remove recursive singleShot calls on feed items, that were creating thousands of timers and causing massive cpu overhead --- retroshare-gui/src/gui/feeds/ChatMsgItem.cpp | 10 +++++----- retroshare-gui/src/gui/feeds/ChatMsgItem.h | 1 + retroshare-gui/src/gui/feeds/SecurityIpItem.cpp | 10 +++++----- retroshare-gui/src/gui/feeds/SecurityIpItem.h | 3 ++- retroshare-gui/src/gui/feeds/SecurityItem.cpp | 9 +++++---- retroshare-gui/src/gui/feeds/SecurityItem.h | 3 ++- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp index 07d2f696d..02b1a3409 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp @@ -67,6 +67,11 @@ ChatMsgItem::ChatMsgItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &pe updateItemStatic(); updateItem(); insertChat(message); + + m_updateTimer = new QTimer(this); + m_updateTimer->setSingleShot(false); + connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updateItem())); + m_updateTimer->start(1000); } void ChatMsgItem::updateItemStatic() @@ -122,11 +127,6 @@ void ChatMsgItem::updateItem() msgButton->setEnabled(false); } } - - /* slow Tick */ - int msec_rate = 10129; - - QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) )); return; } diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.h b/retroshare-gui/src/gui/feeds/ChatMsgItem.h index 421cbfda8..d9216def9 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.h +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.h @@ -60,6 +60,7 @@ private: void insertChat(const std::string &message); RsPeerId mPeerId; + QTimer *m_updateTimer; }; #endif diff --git a/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp b/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp index 6d03cbf56..7d49945b4 100644 --- a/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp @@ -76,6 +76,11 @@ void SecurityIpItem::setup() updateItemStatic(); updateItem(); + + m_updateTimer = new QTimer(this); + m_updateTimer->setSingleShot(false); + connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updateItem())); + m_updateTimer->start(1000); } uint64_t SecurityIpItem::uniqueIdentifier() const @@ -178,11 +183,6 @@ void SecurityIpItem::updateItem() ui->peerDetailsButton->setEnabled(true); } } - - /* slow Tick */ - int msec_rate = 10129; - - QTimer::singleShot( msec_rate, this, SLOT(updateItem(void))); } void SecurityIpItem::toggle() diff --git a/retroshare-gui/src/gui/feeds/SecurityIpItem.h b/retroshare-gui/src/gui/feeds/SecurityIpItem.h index 506bb3de9..58cfc4ff5 100644 --- a/retroshare-gui/src/gui/feeds/SecurityIpItem.h +++ b/retroshare-gui/src/gui/feeds/SecurityIpItem.h @@ -60,12 +60,13 @@ private slots: void banIpListChanged(const QString &ipAddress); private: - RsFeedTypeFlags mType; + RsFeedTypeFlags mType; RsPeerId mSslId; std::string mIpAddr; std::string mIpAddrReported; uint32_t mResult; bool mIsTest; + QTimer *m_updateTimer; /** Qt Designer generated object */ Ui::SecurityIpItem *ui; diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.cpp b/retroshare-gui/src/gui/feeds/SecurityItem.cpp index bf9e0dce6..bec9d019f 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityItem.cpp @@ -93,6 +93,11 @@ SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &g updateItemStatic(); updateItem(); + + m_updateTimer = new QTimer(this); + m_updateTimer->setSingleShot(false); + connect(m_updateTimer, &QTimer::timeout, this, &SecurityItem::updateItem); + m_updateTimer->start(1000); } SecurityItem::~SecurityItem() @@ -303,10 +308,6 @@ void SecurityItem::updateItem() //quickmsgButton->show(); } - /* slow Tick */ - int msec_rate = 10129; - - QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) )); return; } diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.h b/retroshare-gui/src/gui/feeds/SecurityItem.h index 03887c121..6f34af8fe 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.h +++ b/retroshare-gui/src/gui/feeds/SecurityItem.h @@ -66,8 +66,9 @@ private: RsPeerId mSslId; std::string mSslCn; std::string mIP; - RsFeedTypeFlags mType; + RsFeedTypeFlags mType; bool mIsHome; + QTimer *m_updateTimer; RsEventsHandlerId_t mEventHandlerId; };