Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugins/qmlsupport/qmlcontextpropertyadaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

#include <private/qqmlcontext_p.h>
#include <private/qqmlcontextdata_p.h>
#include <private/qv4identifierhashdata_p.h>

#include <QDebug>
#include <QQmlContext>

using namespace GammaRay;

#if QT_VERSION < QT_VERSION_CHECK(6, 12, 0)

QmlContextPropertyAdaptor::QmlContextPropertyAdaptor(QObject *parent)
: PropertyAdaptor(parent)
{
Expand Down Expand Up @@ -107,3 +108,5 @@ QmlContextPropertyAdaptorFactory *QmlContextPropertyAdaptorFactory::instance()
s_instance = new QmlContextPropertyAdaptorFactory;
return s_instance;
}

#endif
4 changes: 4 additions & 0 deletions plugins/qmlsupport/qmlcontextpropertyadaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include <QVector>

#if QT_VERSION < QT_VERSION_CHECK(6, 12, 0)

namespace GammaRay {
class QmlContextPropertyAdaptor : public PropertyAdaptor
{
Expand Down Expand Up @@ -50,3 +52,5 @@ class QmlContextPropertyAdaptorFactory : public AbstractPropertyAdaptorFactory
}

#endif

#endif
2 changes: 2 additions & 0 deletions plugins/qmlsupport/qmlsupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QmlContextExtension>();
PropertyController::registerExtension<QmlTypeExtension>();
Expand Down
21 changes: 2 additions & 19 deletions tests/qmlsupporttest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
Loading