diff --git a/core/probe.cpp b/core/probe.cpp index bb162e56be..0624d9b980 100644 --- a/core/probe.cpp +++ b/core/probe.cpp @@ -865,7 +865,17 @@ void Probe::discoverObject(QObject *object) return; objectAdded(object); - foreach (QObject *child, object->children()) { + + // foreach (QObject *child, object->children()) { + // discoverObject(child); + // } + + const auto children = object->children(); + for (QObject *child : children) { + if (!child) + continue; + if (m_validObjects.contains(child)) + continue; discoverObject(child); } } diff --git a/plugins/quickinspector/quickinspector.cpp b/plugins/quickinspector/quickinspector.cpp index 8a7a7da8be..0c3a7dbbad 100644 --- a/plugins/quickinspector/quickinspector.cpp +++ b/plugins/quickinspector/quickinspector.cpp @@ -512,16 +512,27 @@ void QuickInspector::objectCreated(QObject *object) { if (QQuickWindow *window = qobject_cast(object)) { if (QQuickView *view = qobject_cast(object)) { - m_probe->discoverObject(view->engine()); + if (view->engine()) { + m_probe->discoverObject(view->engine()); + } } else { QQmlContext *context = QQmlEngine::contextForObject(window); QQmlEngine *engine = context ? context->engine() : nullptr; if (!engine) { - engine = qmlEngine(window->contentItem()->childItems().value(0)); + // engine = qmlEngine(window->contentItem()->childItems().value(0)); + QQuickItem *contentItem = window->contentItem(); + if (contentItem) { + const auto children = contentItem->childItems(); + if (!children.isEmpty()) { + engine = qmlEngine(children.first()); + } + } } - m_probe->discoverObject(engine); + if (engine) { + m_probe->discoverObject(engine); + } } } } diff --git a/probe/hooks.cpp b/probe/hooks.cpp index 09ed9d5f22..9c7ff5132f 100644 --- a/probe/hooks.cpp +++ b/probe/hooks.cpp @@ -133,6 +133,10 @@ extern "C" Q_DECL_EXPORT void gammaray_probe_attach() if (!qApp) { return; } + + Hooks::installHooks(); + Probe::startupHookReceived(); + log_injection("gammaray_probe_attach()\n"); new ProbeCreator(ProbeCreator::Create | ProbeCreator::FindExistingObjects | ProbeCreator::ResendServerAddress); } // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)