Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QMutex on Qt 5.7.0

    General and Desktop
    4
    8
    1817
    Loading More Posts
    • 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
      e.capasso last edited by A Former User

      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 ?

      kshegunov 1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

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

        1 Reply Last reply Reply Quote 1
        • kshegunov
          kshegunov Moderators @e.capasso last edited by

          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 Reply Quote 1
          • E
            e.capasso last edited by

            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

            kshegunov 1 Reply Last reply Reply Quote 0
            • kshegunov
              kshegunov Moderators @e.capasso last edited by

              @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 Reply Quote 2
              • E
                e.capasso last edited by

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

                kshegunov JKSH 2 Replies Last reply Reply Quote 0
                • kshegunov
                  kshegunov Moderators @e.capasso last edited by kshegunov

                  @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 Reply Quote 2
                  • JKSH
                    JKSH Moderators @e.capasso last edited by

                    @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 Reply Quote 3
                    • First post
                      Last post