If I change the list of interesters on another thread while using the ejector?
-
When expressing an iterator list in another case while using iterators?
I am using Linux 64Bit Qt 5.4.0 version.
I'm iterating through the list using an iterator, but there are times when the list is cleared or initialized in another thread.
Then, the iterator is not referenced and appears as <not accessible> in debug, and checks such as if (obejct == NULL) do not work.
Is there any way to determine if the reference object has changed and is a garbage value or not a normal value?
-
@Pada_ said in If I change the list of interesters on another thread while using the ejector?:
I'm iterating through the list using an iterator, but there are times when the list is cleared or initialized in another thread.
When you read/write a container from 2 different threads, you must guard access using a
QMutex
orQReadWriteLock
. See https://doc.qt.io/qt-5/threads-reentrancy.htmlThis prevents your iterator from becoming invalid halfway through the process.