MCPcopy Create free account
hub / github.com/KDAB/GammaRay / checkDispatcherStatus

Method checkDispatcherStatus

plugins/timertop/timermodel.cpp:218–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218void TimerModel::checkDispatcherStatus(QObject *object)
219{
220 // m_mutex have to be locked!!
221 static QHash<QAbstractEventDispatcher *, QElapsedTimer> dispatcherChecks;
222 QAbstractEventDispatcher *dispatcher = QAbstractEventDispatcher::instance(object->thread());
223 auto it = dispatcherChecks.find(dispatcher);
224
225 if (it == dispatcherChecks.end()) {
226 it = dispatcherChecks.insert(dispatcher, QElapsedTimer());
227 it.value().start();
228 }
229
230 if (it.value().elapsed() < m_pushTimer->interval())
231 return;
232
233 for (auto gIt = m_gatheredTimersData.begin(), end = m_gatheredTimersData.end(); gIt != end; ++gIt) {
234 QObject *gItObject = gIt.value().info.lastReceiverObject;
235 QAbstractEventDispatcher *gItDispatcher = QAbstractEventDispatcher::instance(gItObject ? gItObject->thread() : nullptr);
236
237 if (gItDispatcher != dispatcher) {
238 if (!gItObject)
239 gIt.value().update(gIt.key(), gItObject);
240 continue;
241 }
242
243 switch (gIt.key().type()) {
244 case TimerId::InvalidType:
245 case TimerId::QQmlTimerType:
246 continue;
247 case TimerId::QTimerType:
248 case TimerId::QObjectType:
249 break;
250 }
251
252 switch (gIt.value().info.state) {
253 case TimerIdInfo::InactiveState:
254 gIt.value().update(gIt.key(), gItObject);
255 case TimerIdInfo::InvalidState:
256 continue;
257 case TimerIdInfo::SingleShotState:
258 case TimerIdInfo::RepeatState:
259 break;
260 }
261
262 int remaining = -1;
263
264 if (gIt.key().timerId() > -1) {
265 remaining = dispatcher->remainingTime(gIt.key().timerId());
266 }
267
268 // Timer inactive or invalid, or free timer
269 if (remaining == -1 || gIt.key().type() == TimerId::QObjectType)
270 gIt.value().update(gIt.key(), gItObject);
271 }
272
273 it.value().restart();
274}
275

Callers 1

eventNotifyCallbackMethod · 0.80

Calls 9

endMethod · 0.80
keyMethod · 0.80
timerIdMethod · 0.80
insertMethod · 0.45
startMethod · 0.45
valueMethod · 0.45
beginMethod · 0.45
updateMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected