Remove recursive singleShot calls on feed items, that were creating thousands of timers and causing massive cpu overhead

This commit is contained in:
jolavillette 2025-12-16 04:42:01 +01:00
parent ed449abb5e
commit dfa9e39612
6 changed files with 20 additions and 16 deletions

View file

@ -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;
}

View file

@ -60,6 +60,7 @@ private:
void insertChat(const std::string &message);
RsPeerId mPeerId;
QTimer *m_updateTimer;
};
#endif

View file

@ -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()

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
};