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 :
Access violation writing location 0x000000000000000C
Access violation writing location 0x000000000000000C
To copy to clipboard, switch view to plain text mode
this is code of unlock :
inline void unlock()
{
if (mut!=nullptr)
{
mut->unlock();
}
}
static QMutex* mut = new QMutex();
inline void unlock()
{
if (mut!=nullptr)
{
mut->unlock();
}
}
To copy to clipboard, switch view to plain text mode
and this is part of code in run method i want to lock:
mut->lock();
cv::Mat imgRGB; cv::cvtColor(out, imgRGB, CV_BGR2RGB);
QImage img
(imgRGB.
data, imgRGB.
cols, imgRGB.
rows, static_cast<int>
(imgRGB.
step),
outPut
->setPixmap
(QPixmap::fromImage(img
));
mut->unlock();
mut->lock();
cv::Mat imgRGB; cv::cvtColor(out, imgRGB, CV_BGR2RGB);
QImage img(imgRGB.data, imgRGB.cols, imgRGB.rows, static_cast<int>(imgRGB.step),
QImage::Format_RGB888);
outPut->setPixmap(QPixmap::fromImage(img));
mut->unlock();
To copy to clipboard, switch view to plain text mode
Bookmarks