Merge integration refs/builds/qtci/dev/1618385170

This commit is contained in:
Qt CI Bot 2021-04-14 10:37:33 +00:00
commit 38abdd33f1
3 changed files with 27 additions and 6 deletions

View File

@ -577,7 +577,7 @@ public:
bool isBindable() const { return iface && iface->getBinding; }
bool isReadOnly() const { return !(iface && iface->setBinding && iface->setObserver); }
QUntypedPropertyBinding makeBinding(const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION)
QUntypedPropertyBinding makeBinding(const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
{
return iface ? iface->makeBinding(data, location) : QUntypedPropertyBinding();
}
@ -597,14 +597,14 @@ public:
return binding;
}
void observe(QPropertyObserver *observer)
void observe(QPropertyObserver *observer) const
{
if (iface)
iface->setObserver(data, observer);
}
template<typename Functor>
QPropertyChangeHandler<Functor> onValueChanged(Functor f)
QPropertyChangeHandler<Functor> onValueChanged(Functor f) const
{
QPropertyChangeHandler<Functor> handler(f);
observe(&handler);
@ -612,7 +612,7 @@ public:
}
template<typename Functor>
QPropertyChangeHandler<Functor> subscribe(Functor f)
QPropertyChangeHandler<Functor> subscribe(Functor f) const
{
f();
return onValueChanged(f);
@ -658,7 +658,7 @@ public:
}
}
QPropertyBinding<T> makeBinding(const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION)
QPropertyBinding<T> makeBinding(const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
{
return static_cast<QPropertyBinding<T> &&>(QUntypedBindable::makeBinding(location));
}

View File

@ -12,7 +12,7 @@ endif()
# Only include the following tools when performing a host build
if(NOT CMAKE_CROSSCOMPILING)
add_subdirectory(androiddeployqt)
if(QT_FEATURE_gui)
if(QT_FEATURE_gui AND QT_FEATURE_systemsemaphore)
add_subdirectory(androidtestrunner)
endif()
endif()

View File

@ -80,6 +80,7 @@ private slots:
void typeNoOperatorEqual();
void bindingValueReplacement();
void quntypedBindableApi();
void readonlyConstQBindable();
void testNewStuff();
void qobjectObservers();
@ -1030,6 +1031,26 @@ void tst_QProperty::quntypedBindableApi()
QVERIFY(propLess.takeBinding().isNull());
}
void tst_QProperty::readonlyConstQBindable()
{
QProperty<int> i {42};
const QBindable<int> bindableI(const_cast<const QProperty<int> *>(&i));
// check that read-only operations work with a const QBindable
QVERIFY(bindableI.isReadOnly());
QVERIFY(!bindableI.hasBinding());
// we can still create a binding to a read only bindable through the interface
QProperty<int> j;
j.setBinding(bindableI.makeBinding());
QCOMPARE(j.value(), bindableI.value());
int counter = 0;
auto observer = bindableI.subscribe([&](){++counter;});
QCOMPARE(counter, 1);
auto observer2 = bindableI.onValueChanged([&](){++counter;});
i = 0;
QCOMPARE(counter, 3);
}
class MyQObject : public QObject
{
Q_OBJECT