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. QMutex on Qt 5.7.0

QMutex on Qt 5.7.0

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 2.2k Views
  • 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.
  • E Offline
    E Offline
    e.capasso
    wrote on last edited by A Former User
    #1

    I try to recompile an application developed on Qt 5.5.0 on new Qt 5.7.0, the first problem that compiler has shown is that QMutex include miss (but Qt 5.5.0 doesn't give me this problem).

    After i have added QMutex include and all compile, but when application is closed, it seems that qmutex is not destroyed and i receive an exception .

    Are there different Handling on QMutex on Qt 5.5.0 and Qt 5.7.0 ?

    kshegunovK 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Its hard to imagine huge changes as its same uses cases still.
      What exception is shown?

      1 Reply Last reply
      1
      • E e.capasso

        I try to recompile an application developed on Qt 5.5.0 on new Qt 5.7.0, the first problem that compiler has shown is that QMutex include miss (but Qt 5.5.0 doesn't give me this problem).

        After i have added QMutex include and all compile, but when application is closed, it seems that qmutex is not destroyed and i receive an exception .

        Are there different Handling on QMutex on Qt 5.5.0 and Qt 5.7.0 ?

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #3

        After the exception is thrown interrupt the debugger (if not done automatically) and post the stack trace here. As far as I know there are no changes in the mutex implementation between the mentioned Qt versions.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        1
        • E Offline
          E Offline
          e.capasso
          wrote on last edited by
          #4

          I have observed that in QT 5.5.0 i have the print "QMutex: destroying locked mutex" when i close application in QT 5.7.0 i have exception instead and no print

          kshegunovK 1 Reply Last reply
          0
          • E e.capasso

            I have observed that in QT 5.5.0 i have the print "QMutex: destroying locked mutex" when i close application in QT 5.7.0 i have exception instead and no print

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @e.capasso said in QMutex on QT 5.7.0:

            QMutex: destroying locked mutex

            That's pretty descriptive. You don't unlock a mutex and you exit the application instead. You should fix this so you get a graceful close sequence (i.e. freeing your resources).

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            2
            • E Offline
              E Offline
              e.capasso
              wrote on last edited by
              #6

              i suspect the some problem, but my question is why the same project in QT5.5.0 closes itself graceful?

              kshegunovK JKSHJ 2 Replies Last reply
              0
              • E e.capasso

                i suspect the some problem, but my question is why the same project in QT5.5.0 closes itself graceful?

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by kshegunov
                #7

                @e.capasso said in QMutex on QT 5.7.0:

                why the same project in QT5.5.0 closes itself graceful

                It doesn't close gracefully, you get a fat warning from Qt. Why it works no one can tell you. Closing the application while a mutex is locked falls into the "undefined behavior" section, thus it may work (as with Qt 5.5) or it may not (as with Qt 5.7).

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                2
                • E e.capasso

                  i suspect the some problem, but my question is why the same project in QT5.5.0 closes itself graceful?

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

                  @e.capasso said in QMutex on QT 5.7.0:

                  why the same project in QT5.5.0 closes itself graceful?

                  It was not graceful. You must make sure that your program unlocks all mutexes before quitting.

                  Destroying a locked mutex leads to undefined behaviour. So, your program didn't crash in Qt 5.5.0 only because you were "lucky".

                  See the code and documentation at https://code.woboq.org/qt5/qtbase/src/corelib/thread/qmutex.cpp.html#188 -- The warning about undefined behaviour is supposed to be documented at http://doc.qt.io/qt-5/qmutex.html but it seems to be missing.

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

                  1 Reply Last reply
                  3

                  • Login

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