From 50e10af7c0261691751443e10b271e32364c91a7 Mon Sep 17 00:00:00 2001 From: Rafal Andrusieczko Date: Fri, 14 Mar 2025 15:03:27 +0100 Subject: [PATCH] QmlDesigner: add verification that the function exists Add verification that the function exists before invoking it. It causes warnings when the method does not exist in a pane. Also all of the panes don't need this. In addition, removing the placeholder with an empty function, as it is no longer needed. Task-number: QDS-14709 Change-Id: Ieaff5cf4759514c84e09ca0faaecc22b357b9a94 Reviewed-by: Ali Kianian Reviewed-by: Mahmoud Badri --- .../propertyEditorQmlSources/QtQuick/emptyPane.qml | 5 ----- .../components/propertyeditor/propertyeditorview.cpp | 9 ++++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/emptyPane.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/emptyPane.qml index c797860c762..3ec325d8f14 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/emptyPane.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/emptyPane.qml @@ -13,11 +13,6 @@ Rectangle { height: 400 color: StudioTheme.Values.themePanelBackground - // Called from C++ to clear the search when the selected node changes - function clearSearch() { - // The function is empty, because it is a placeholder to match other panes - } - ColumnLayout { id: mainColumn anchors.fill: parent diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp index aa81d3b6d11..86ee06fec7e 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp @@ -453,7 +453,14 @@ void PropertyEditorView::resetView() if (m_qmlBackEndForCurrentType) { m_qmlBackEndForCurrentType->emitSelectionChanged(); - QMetaObject::invokeMethod(m_qmlBackEndForCurrentType->widget()->rootObject(), "clearSearch"); + + const auto qmlBackEndObject = m_qmlBackEndForCurrentType->widget()->rootObject(); + if (qmlBackEndObject) { + const auto metaObject = qmlBackEndObject->metaObject(); + const int methodIndex = metaObject->indexOfMethod("clearSearch()"); + if (methodIndex != -1) + metaObject->method(methodIndex).invoke(qmlBackEndObject); + } } m_locked = false;