'lock' is not a member of 'QMutex' ???



  • Hi there!

    Whenever I include <QMutex>, I'm getting the following errors:

    c:\qt\5.10.1\msvc2017_64\include\qtcore\qmutex.h(206): error C2039: 'lock': n'est pas membre de 'QMutex'
    c:\qt\5.10.1\msvc2017_64\include\qtcore\qmutex.h(126): note: voir la déclaration de 'QMutex'
    c:\qt\5.10.1\msvc2017_64\include\qtcore\qmutex.h(227): error C2039: 'lock': n'est pas membre de 'QMutex'
    c:\qt\5.10.1\msvc2017_64\include\qtcore\qmutex.h(126): note: voir la déclaration de 'QMutex'
    

    That's basically saying that 'lock' is not a member of 'QMutex' ! Looking at the qmutex.h header, that's indeed true: there's no lock() method.

    Looking at the diff between MSVC 2015 & 2017 :

    --- C:\Qt\5.10.1\msvc2015_64\include\QtCore\qmutex.h
    +++ C:\Qt\5.10.1\msvc2017_64\include\QtCore\qmutex.h
    @@ -74,7 +74,7 @@
     #endif
     
         // BasicLockable concept
    -    inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
    +    inline void ScopedLock() QT_MUTEX_LOCK_NOEXCEPT {
             if (!fastTryLock())
                 lockInternal();
         }
    @@ -131,7 +131,7 @@
         ~QMutex();
     
         // BasicLockable concept
    -    void lock() QT_MUTEX_LOCK_NOEXCEPT;
    +    void ScopedLock() QT_MUTEX_LOCK_NOEXCEPT;
         bool tryLock(int timeout = 0) QT_MUTEX_LOCK_NOEXCEPT;
         // BasicLockable concept
         void unlock() Q_DECL_NOTHROW;
    

    The lock() method disappeared in favor of ScopedLock() ? Editing the header fixed it, did I missed something ?

    Qt 5.10.1 (i386-little_endian-ilp32 shared (dynamic) release build; by MSVC 2015) on "windows"
    OS: Windows 10 (10.0) [winnt version 10.0.16299]
    Architecture: x86_64; features: SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 AVX AVX2 RTM HLE


  • Moderators

    @renaud said in 'lock' is not a member of 'QMutex' ???:

    The lock() method disappeared in favor of ScopedLock() ? I'm stuck. Any help?

    I think you might have accidentally modified qmutex.h on your PC, because there is no function called ScopedLock() in Qt 5. Did you do a mass find-and-replace recently? Do any of your projects have a function or variable called "ScopedLock"?

    Anyway, if you edit the header to rename "ScopedLock" back to "lock", and this error will disappear. However, we don't know if anything else in your Qt installation has been corrupted. To be 100% certain, uninstall and re-install Qt 5.10.1 for MSVC 2017.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.