Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. 'lock' is not a member of 'QMutex' ???
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 546 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    renaud
    wrote on last edited by renaud
    #1

    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

    JKSHJ 1 Reply Last reply
    0
    • R renaud

      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

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by JKSH
      #2

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

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      4

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved