From dceafe19c3fe61844482d75e7cce8402096ad2b3 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 27 Jul 2026 13:45:44 +0500 Subject: [PATCH] Remove support for QML Context property The APIs that were being used are no longer exported by Qt. --- .../qmlsupport/qmlcontextpropertyadaptor.cpp | 5 ++++- .../qmlsupport/qmlcontextpropertyadaptor.h | 4 ++++ plugins/qmlsupport/qmlsupport.cpp | 2 ++ tests/qmlsupporttest.cpp | 21 ++----------------- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/plugins/qmlsupport/qmlcontextpropertyadaptor.cpp b/plugins/qmlsupport/qmlcontextpropertyadaptor.cpp index 663e468719..69459feb9a 100644 --- a/plugins/qmlsupport/qmlcontextpropertyadaptor.cpp +++ b/plugins/qmlsupport/qmlcontextpropertyadaptor.cpp @@ -17,13 +17,14 @@ #include #include -#include #include #include using namespace GammaRay; +#if QT_VERSION < QT_VERSION_CHECK(6, 12, 0) + QmlContextPropertyAdaptor::QmlContextPropertyAdaptor(QObject *parent) : PropertyAdaptor(parent) { @@ -107,3 +108,5 @@ QmlContextPropertyAdaptorFactory *QmlContextPropertyAdaptorFactory::instance() s_instance = new QmlContextPropertyAdaptorFactory; return s_instance; } + +#endif diff --git a/plugins/qmlsupport/qmlcontextpropertyadaptor.h b/plugins/qmlsupport/qmlcontextpropertyadaptor.h index 8e0ed0f591..1c5a28ba16 100644 --- a/plugins/qmlsupport/qmlcontextpropertyadaptor.h +++ b/plugins/qmlsupport/qmlcontextpropertyadaptor.h @@ -19,6 +19,8 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 12, 0) + namespace GammaRay { class QmlContextPropertyAdaptor : public PropertyAdaptor { @@ -50,3 +52,5 @@ class QmlContextPropertyAdaptorFactory : public AbstractPropertyAdaptorFactory } #endif + +#endif diff --git a/plugins/qmlsupport/qmlsupport.cpp b/plugins/qmlsupport/qmlsupport.cpp index 795decd9b3..5c0b307ff9 100644 --- a/plugins/qmlsupport/qmlsupport.cpp +++ b/plugins/qmlsupport/qmlsupport.cpp @@ -318,7 +318,9 @@ QmlSupport::QmlSupport(Probe *probe, QObject *parent) PropertyAdaptorFactory::registerFactory(QmlListPropertyAdaptorFactory::instance()); PropertyAdaptorFactory::registerFactory(QmlAttachedPropertyAdaptorFactory::instance()); PropertyAdaptorFactory::registerFactory(QJSValuePropertyAdaptorFactory::instance()); +#if QT_VERSION < QT_VERSION_CHECK(6, 12, 0) PropertyAdaptorFactory::registerFactory(QmlContextPropertyAdaptorFactory::instance()); +#endif PropertyController::registerExtension(); PropertyController::registerExtension(); diff --git a/tests/qmlsupporttest.cpp b/tests/qmlsupporttest.cpp index 0bc9c4010f..b98eb50852 100644 --- a/tests/qmlsupporttest.cpp +++ b/tests/qmlsupporttest.cpp @@ -56,7 +56,9 @@ private slots: PropertyAdaptorFactory::registerFactory(QmlListPropertyAdaptorFactory::instance()); PropertyAdaptorFactory::registerFactory(QmlAttachedPropertyAdaptorFactory::instance()); PropertyAdaptorFactory::registerFactory(QJSValuePropertyAdaptorFactory::instance()); +#if QT_VERSION < QT_VERSION_CHECK(6, 12, 0) PropertyAdaptorFactory::registerFactory(QmlContextPropertyAdaptorFactory::instance()); +#endif } void testQmlListProperty() @@ -157,25 +159,6 @@ Rectangle { delete obj; } - - void testContextProperty() - { - QQmlEngine engine; - engine.rootContext()->setContextProperty("myContextProp", 42); - - auto adaptor = PropertyAdaptorFactory::create(engine.rootContext(), this); - QVERIFY(adaptor); - - auto idx = indexOfProperty(adaptor, "myContextProp"); - QVERIFY(idx >= 0); - - auto data = adaptor->propertyData(idx); - QCOMPARE(data.name(), QStringLiteral("myContextProp")); - QCOMPARE(data.value().toInt(), 42); - - adaptor->writeProperty(idx, 23); - QCOMPARE(engine.rootContext()->contextProperty("myContextProp").toInt(), 23); - } }; QTEST_MAIN(QmlSupportTest)