Results 1 to 2 of 2

Thread: Access violation writing location 0x000000000000000C Exception when try QMutex.unloc

  1. #1
    Join Date
    Aug 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Access violation writing location 0x000000000000000C Exception when try QMutex.unloc

    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 

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Access violation writing location 0x000000000000000C Exception when try QMutex.un

    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?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. access violation writing location
    By Algos in forum Qt Programming
    Replies: 2
    Last Post: 9th April 2016, 13:08
  2. Replies: 4
    Last Post: 29th February 2016, 17:47
  3. Replies: 3
    Last Post: 24th April 2012, 01:06
  4. Access Violation with VS2008
    By Takatschio in forum Qt Programming
    Replies: 3
    Last Post: 19th August 2010, 10:16
  5. dll exception: int at memory location errors
    By jeffpogo in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2009, 21:01

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.