I have QMutex and QQueue as member in QThread based class. I'm locking QMutex (by QMutexLocker) in popEvent and pushEvent metods. When I lock it in push method called from main thread it works. When I call pop function from child thread loop it crashes on creating QMutexLock. Whats wrong? Should QMutex and QQueue be global or static? QThread based class is created on main thread heap (heap not stack).
Asked
Active
Viewed 395 times
1
-
Please edit your question to provide a [mcve] that demonstrates the problem. – G.M. Mar 01 '18 at 11:14
1 Answers
0
A mutex is "owned" by the thread that holds it. It cannot be released by another thread. You probably want a semaphore, not a mutex.

David Schwartz
- 179,497
- 17
- 214
- 278