Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QMutex: destroying locked mutex



  • Hello friends.

    Im beginner in Qt. I watched Voidrealms tutorial (C++ Qt 31 - QThread part 4 threads with a GUI). when i want to create & run similar project, in Application output appears "QMutex: destroying locked mutex" & the thread doesnt work. even original project that wriitten by voidRealms doesnt work for me. whats the problem?

    Thanks a lot.
    Ya Ali.


  • Moderators

    If you can't avoid locking in your code, I think the best best solution is to use QMutexLocker class: it is much less error-prone.



  • Hi Mohammad

    Did you get your answer? I have the same issue. How far you have gone in that set of videos?

    Thanks



  • Hi dear Saham.

    I didn`t use mutex after this question but I think my problem solved by adding QObject::connect to connect signal & slot!
    I had forgotten to add this code! :)



  • but it didnt help me. So I am going to give up and move on :)



  • Did you include #include <QThread> in mythread.h? change it to #include <QtCore> to solve problem


  • Moderators

    [quote author="itsi" date="1398243096"]Did you include #include <QThread> in mythread.h? change it to #include <QtCore> to solve problem[/quote]

    I would not recommend this. Including the whole QtCore will increase the compilation time a lot. Include only what you use, use forward declarations where possible, and you will compile about 40% faster.



  • Thanks sierdzio for recommendation, QThread is enough and faster.
    I found solution for sole problem:
    Just add thread->Stop = false in Start button's triggered to make sure it starts.



  • i confirm that what @itsi recommends really helped. thanks a lot!


Log in to reply