Distinguish property change signals from user-defined signals
Do not expose this information to qmltypes just yet, though, as this seems irrelevant at the moment Pick-to: 6.3 Change-Id: Iffd8901ef9899a0fff226e8799bf45c1d688b92b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
parent
bb911a16aa
commit
b1bb4c8e5f
|
@ -192,6 +192,12 @@ public:
|
|||
m_isJavaScriptFunction = isJavaScriptFunction;
|
||||
}
|
||||
|
||||
bool isImplicitQmlPropertyChangeSignal() const { return m_isImplicitQmlPropertyChangeSignal; }
|
||||
void setIsImplicitQmlPropertyChangeSignal(bool isPropertyChangeSignal)
|
||||
{
|
||||
m_isImplicitQmlPropertyChangeSignal = isPropertyChangeSignal;
|
||||
}
|
||||
|
||||
bool isValid() const { return !m_name.isEmpty(); }
|
||||
|
||||
const QVector<QQmlJSAnnotation>& annotations() const { return m_annotations; }
|
||||
|
@ -253,6 +259,7 @@ private:
|
|||
int m_revision = 0;
|
||||
bool m_isConstructor = false;
|
||||
bool m_isJavaScriptFunction = false;
|
||||
bool m_isImplicitQmlPropertyChangeSignal = false;
|
||||
};
|
||||
|
||||
class QQmlJSMetaProperty
|
||||
|
|
|
@ -123,6 +123,7 @@ void QQmlJSScope::insertPropertyIdentifier(const QQmlJSMetaProperty &property)
|
|||
addOwnProperty(property);
|
||||
QQmlJSMetaMethod method(property.propertyName() + u"Changed"_qs, u"void"_qs);
|
||||
method.setMethodType(QQmlJSMetaMethod::Signal);
|
||||
method.setIsImplicitQmlPropertyChangeSignal(true);
|
||||
addOwnMethod(method);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import QtQml
|
||||
QtObject {
|
||||
property string myProperty: "foobar"
|
||||
|
||||
signal mySignal()
|
||||
|
||||
property int conflictingProperty: 42
|
||||
signal conflictingPropertyChanged(a: real, c: string)
|
||||
}
|
|
@ -97,6 +97,7 @@ private Q_SLOTS:
|
|||
void initTestCase() override;
|
||||
|
||||
void orderedBindings();
|
||||
void signalCreationDifferences();
|
||||
|
||||
public:
|
||||
tst_qqmljsscope() : QQmlDataTest(QT_QMLTEST_DATADIR) { }
|
||||
|
@ -140,5 +141,27 @@ void tst_qqmljsscope::orderedBindings()
|
|||
QCOMPARE(std::next(itemsBindingsBegin)->objectType()->baseTypeName(), u"Text"_qs);
|
||||
}
|
||||
|
||||
void tst_qqmljsscope::signalCreationDifferences()
|
||||
{
|
||||
QQmlJSScope::ConstPtr root = run(u"signalCreationDifferences.qml"_qs);
|
||||
QVERIFY(root);
|
||||
|
||||
QVERIFY(root->hasOwnProperty(u"myProperty"_qs));
|
||||
QVERIFY(root->hasOwnProperty(u"conflictingProperty"_qs));
|
||||
QCOMPARE(root->ownMethods(u"mySignal"_qs).size(), 1);
|
||||
|
||||
const auto conflicting = root->ownMethods(u"conflictingPropertyChanged"_qs);
|
||||
QCOMPARE(conflicting.size(), 2);
|
||||
QCOMPARE(conflicting[0].methodType(), QQmlJSMetaMethod::Signal);
|
||||
QCOMPARE(conflicting[1].methodType(), QQmlJSMetaMethod::Signal);
|
||||
|
||||
const QQmlJSMetaMethod *explicitMethod = nullptr;
|
||||
if (conflicting[0].isImplicitQmlPropertyChangeSignal())
|
||||
explicitMethod = &conflicting[1];
|
||||
else
|
||||
explicitMethod = &conflicting[0];
|
||||
QCOMPARE(explicitMethod->parameterNames(), QStringList({ u"a"_qs, u"c"_qs }));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_qqmljsscope)
|
||||
#include "tst_qqmljsscope.moc"
|
||||
|
|
Loading…
Reference in New Issue