void WatcherRunner::start() { // Set worker performance counters to an initial state. Watcher::resetWorkerCounters(0); // Enter the watch loop. do { if (use_worker_ && !watch(Watcher::getWorker())) { if (Watcher::fatesBound()) { // A signal has interrupted the watcher. break; } // The watcher failed, create a worker. createWorker(); } // Loop over every managed extension and check sanity. std::vector<std::string> failing_extensions; for (const auto& extension : Watcher::extensions()) { if (!watch(*extension.second)) { if (!createExtension(extension.first)) { failing_extensions.push_back(extension.first); } } } // If any extension creations failed, stop managing them. for (const auto& failed_extension : failing_extensions) { Watcher::removeExtensionPath(failed_extension); } pauseMilli(getWorkerLimit(INTERVAL) * 1000); } while (!interrupted() && ok()); }
QObject *QExtensionFactory::extension(QObject *object, const QString &iid) const { if (!object) return 0; QPair<QString, QObject*> key = qMakePair(iid, object); if (!m_extensions.contains(key)) { if (QObject *ext = createExtension(object, iid, const_cast<QExtensionFactory*>(this))) { connect(ext, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*))); m_extensions.insert(key, ext); } }
QObject *QExtensionFactory::extension(QObject *object, const QString &iid) const { if (!object) return 0; const IdObjectKey key = qMakePair(iid, object); ExtensionMap::iterator it = m_extensions.find(key); if (it == m_extensions.end()) { if (QObject *ext = createExtension(object, iid, const_cast<QExtensionFactory*>(this))) { connect(ext, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*))); it = m_extensions.insert(key, ext); } }