简体   繁体   中英

Crash creating QMutexLocker from child QThread

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM