i have five class inherited from QThread that run all together and every class have own GUI resource like QLable* that get from main GUI thread. but when i start this five after some second exception occur. for resolve this i use global static Qmutex to lock/unlock part of code in run method.now i have button in main tread and want when press terminate all threads and unlock code but when Qmutex.unlock execute this exception rised :
Qt Code:
  1. Access violation writing location 0x000000000000000C
To copy to clipboard, switch view to plain text mode 

this is code of unlock :
Qt Code:
  1. static QMutex* mut = new QMutex();
  2. inline void unlock()
  3. {
  4. if (mut!=nullptr)
  5. {
  6. mut->unlock();
  7. }
  8. }
To copy to clipboard, switch view to plain text mode 

and this is part of code in run method i want to lock:
Qt Code:
  1. mut->lock();
  2. cv::Mat imgRGB; cv::cvtColor(out, imgRGB, CV_BGR2RGB);
  3. QImage img(imgRGB.data, imgRGB.cols, imgRGB.rows, static_cast<int>(imgRGB.step),
  4. QImage::Format_RGB888);
  5. outPut->setPixmap(QPixmap::fromImage(img));
  6. mut->unlock();
To copy to clipboard, switch view to plain text mode