PDA

View Full Version : good approach? (QAbstractItemModel with a read-write lock)



jajdoo
12th November 2011, 16:42
(note : i have little experience with multithreading and thread safety)

i needed my item model to interact with objects from different threads, so i added a QReadWriteLock to the model (specified it mutable), and lock from any call that either read or writes (made sure that a the model doesn't deadlock itself logic-wise)

is this a good approach, or am i planting landmines?

grin
12th November 2011, 21:28
Hi, I think it's a good approach.
And... I think than using QReadLocker and QWriteLocker is more safe than QReadWriteLock::lock(), QReadWriteLock::unlock() =)

wysota
14th November 2011, 11:24
It is not a very good approach however it shouldn't blow up in your face. Please specify how are you accessing the model from different threads and why.