QMutexLocker with Q_GLOBAL_STATIC
Solved
General and Desktop
-
Hi,
i change my code to Qt 6 and get a compilation errer with QMutexLocker and a Q_GLOBAL_STATIC variable. The error occours not in Qt 5.15.Qt 6.5, MSVC2019, 64 bit, Win10
Q_GLOBAL_STATIC(QMutex, mutex) ... void myFun() { QMutexLocker locker(&mutex); //C2039, "lock" is not a member of "QGlobalStatic<QtGlobalStatic::Holder<`anonymous-namespace'::Q_QGS_m_mutex>>" }
-
@beecksche said in QMutexLocker with Q_GLOBAL_STATIC:
Q_GLOBAL_STATIC(QMutex, mutex)
Why does it have to be global static?
-
@jsulm said in QMutexLocker with Q_GLOBAL_STATIC:
Why does it have to be global static?
Because of ... reasons ... No, you're absolutely right:
QMutex mutex; ... void myFun() { QMutexLocker locker(&mutex); }
is totally sufficient. (And works by the way). Thanks
-