QList<*QObject> property thread safety
Unsolved
QML and Qt Quick
-
They work on separate copies of the list.
-
@poncho524 said in QList<*QObject> property thread safety:
if one thread is updating a QList<*QObjects> and the qml thread is using this as a ListView model, how can thread safety be guarenteed?
There's a multithreading list model example that covers updating a ListModel outside of the gui thread.
The Qt containers are documented as thread-safe only if the container is read-only. Otherwise, mutual exclusion is necessary to protect accesses.
QObject also isn't thread safe. If they are allocated in a worker thread, don't forget to QObject::moveToThread() before the gui thread has an opportunity for access. Once that is done, the worker thread can't safely access the object.