Exemplo n.º 1
0
bool TimerModel::eventFilter(QObject *watched, QEvent *event)
{
    if (event->type() == QEvent::Timer) {
        QTimerEvent * const timerEvent = static_cast<QTimerEvent *>(event);

        // If there is a QTimer associated with this timer ID, don't handle it here, it will be handled
        // by the signal hooks for QTimer::timeout()
        if (findOrCreateQTimerTimerInfo(timerEvent->timerId()))
            return false;

        // check if object is owned by GammaRay itself
        if (m_probe && m_probe->filterObject(watched))
            return false;

        const TimerInfoPtr timerInfo = findOrCreateFreeTimerInfo(timerEvent->timerId());
        TimerInfo::TimeoutEvent timeoutEvent;
        timeoutEvent.timeStamp = QTime::currentTime();
        timeoutEvent.executionTime = -1;
        timerInfo->addEvent(timeoutEvent);

        timerInfo->setLastReceiver(watched);
        emitFreeTimerChanged(m_freeTimers.indexOf(timerInfo));
    }
    return false;
}
Exemplo n.º 2
0
bool TimerModel::eventFilter(QObject *watched, QEvent *event)
{
    if (event->type() == QEvent::Timer) {

        QTimerEvent * const timerEvent = dynamic_cast<QTimerEvent*>(event);
        Q_ASSERT(timerEvent);

        // If there is a QTimer associated with this timer ID, don't handle it here, it will be handled
        // by the signal hooks for QTimer::timeout()
        if (findOrCreateQTimerTimerInfo(timerEvent->timerId())) {
            return false;
        }

        if (Probe::instance()->filterObject(watched)) {
            return false;
        }

        const TimerInfoPtr timerInfo = findOrCreateFreeTimerInfo(timerEvent->timerId());
        TimerInfo::TimeoutEvent timeoutEvent;
        timeoutEvent.timeStamp = QTime::currentTime();
        timeoutEvent.executionTime = -1;
        timerInfo->addEvent(timeoutEvent);

        timerInfo->setLastReceiver(watched);
    }
    return false;
}
Exemplo n.º 3
0
void TimerModel::postSignalActivate(QObject *caller, int methodIndex)
{
  QHash<QObject*, TimerInfoPtr>::iterator it = m_currentSignals.find(caller);
  if (it == m_currentSignals.end()) {
    // Ok, likely a GammaRay timer
    // cout << "TimerModel::postSignalActivate(): Unable to find timer "
    //      << (void*)caller << " (" << caller->objectName().toStdString() << ")!" << endl;
    return;
  }

  const TimerInfoPtr timerInfo = *it;
  Q_ASSERT(timerInfo);

  if (!(timerInfo->type() == TimerInfo::QTimerType && methodIndex == m_timeoutIndex) &&
      !(timerInfo->type() == TimerInfo::QQmlTimerType && methodIndex == m_qmlTimerTriggeredIndex))
  {
    return;
  }

  m_currentSignals.erase(it);

  if (!timerInfo->timerObject()) {
    // timer got killed in a slot
    return;
  }

  Q_ASSERT(caller == timerInfo->timerObject());

  if (!timerInfo->functionCallTimer()->active()) {
    cout << "TimerModel::postSignalActivate(): Timer not active: "
          << (void*)caller << " (" << caller->objectName().toStdString() << ")!" << endl;
    return;
  }

  TimerInfo::TimeoutEvent event;
  event.timeStamp = QTime::currentTime();
  event.executionTime = timerInfo->functionCallTimer()->stop();
  timerInfo->addEvent(event);
  const int row = rowFor(timerInfo->timerObject());
  emitTimerObjectChanged(row);
}
Exemplo n.º 4
0
void TimerModel::postSignalActivate(QObject *caller, int methodIndex)
{
  if (methodIndex != m_timeoutIndex) {
    return;
  }
  QHash<QObject*, TimerInfoPtr>::iterator it = m_currentSignals.find(caller);
  if (it == m_currentSignals.end()) {
    // Ok, likely a GammaRay timer
    //cout << "TimerModel::postSignalActivate(): Unable to find timer "
    //     << (void*)timer << " (" << timer->objectName().toStdString() << ")!" << endl;
    return;
  }

  const TimerInfoPtr timerInfo = *it;
  Q_ASSERT(timerInfo);

  m_currentSignals.erase(it);

  if (!timerInfo->timer()) {
    // timer got killed in a slot
    return;
  }

  Q_ASSERT(static_cast<QTimer*>(caller) == timerInfo->timer());

  if (!timerInfo->functionCallTimer()->active()) {
    cout << "TimerModel::postSignalActivate(): Timer not active: "
          << (void*)caller << " (" << caller->objectName().toStdString() << ")!" << endl;
    return;
  }

  TimerInfo::TimeoutEvent event;
  event.timeStamp = QTime::currentTime();
  event.executionTime = timerInfo->functionCallTimer()->stop();
  timerInfo->addEvent(event);
  const int row = rowFor(timerInfo->timer());
  if (row != -1) {
    emit dataChanged(index(row, 0), index(row, columnCount() - 1));
  }
}
Exemplo n.º 5
0
void TimerModel::postSignalActivate(QTimer *timer)
{
    const TimerInfoPtr timerInfo = findOrCreateQTimerTimerInfo(timer);
    if (timerInfo) {
        if (!timerInfo->functionCallTimer()->active()) {
            cout << "TimerModel::postSignalActivate(): Timer not active: "
                 << (void*)timer << " (" << timer->objectName().toStdString() << ")!" << endl;
        } else {
            TimerInfo::TimeoutEvent event;
            event.timeStamp = QTime::currentTime();
            event.executionTime = timerInfo->functionCallTimer()->stop();
            timerInfo->addEvent(event);
            const int row = rowFor(timer);
            if (row != -1) {
                emit dataChanged(index(row, 0), index(row, columnCount() - 1));
            }
        }
    } else {
        // Ok, likely a GammaRay timer
        //cout << "TimerModel::postSignalActivate(): Unable to find timer "
        //     << (void*)timer << " (" << timer->objectName().toStdString() << ")!" << endl;
    }
}