PDA

View Full Version : Access violation writing location 0x000000000000000C Exception when try QMutex.unloc



aligoglos
11th August 2017, 11:13
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

this is code of unlock :

static QMutex* mut = new QMutex();
inline void unlock()
{
if (mut!=nullptr)
{
mut->unlock();
}
}

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),
QImage::Format_RGB888);
outPut->setPixmap(QPixmap::fromImage(img));
mut->unlock();

high_flyer
11th August 2017, 15:57
can you show the whole scope in which the code is in?
This sounds very much like a bad pointer - but its hard to tell from the code as you posted it.
In the second code snippet you use mut->unlock() yet in the upper snipped you defined an inline wrapper function unlock() which you are not using...?
Where in the sscond snipped is mun initialized?