Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
5.15.2
Description
Edit: Not related to threading - that part was an error in my reproduction.
When a changed signal is emitted from another Thread - which is thread safe (Edit: unrelated to threads) the would-be-removed property binding still updates the TextField, overwriting any User Input.
FYI in case this needs small changes to compile, I renamed things for the reproduction example here after confirming the bug
Assume I have a Qt Quick Controls 2 TextField, which auto-binds to MyClass.testProperty
import QtQuick.Controls 2.15 // .... TextField { text: MyClass.testProperty height: 64 width: 200 }
And a class MyClass, which defines said property, returning a new value every time.
class MyClass : public QObject { Q_OBJECT public: explicit MyClass(); ~MyClass(); Q_PROPERTY(QString testProperty READ testProperty WRITE setTestProperty NOTIFY testPropertyChanged) QString testProperty() { static int testPropValue = 0; return QString::number(testPropValue++); }; void setTestProperty(QString) { qInfo("This is not part of the example"); exit(1); }; signals: void testPropertyChanged(); }
With the class constructor starting a timer on another thread:
MyClass::MyClass() : QObject(nullptr) { auto timer = new QTimer; timer->setInterval(2000); timer->start(2000); QObject::connect(timer, &QTimer::timeout, this, &MyClass::testPropertyChanged); }
Which is given to the QmlEngine.:
// ... qmlAppEngine->rootContext()->setContextProperty("MyClass", new MyClass); // ...
I now observe that if I type into the InputField, the contents are still reset to the number every two seconds.