Results 1 to 2 of 2

Thread: Mutex unlock without locking it

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Mutex unlock without locking it

    Hi,

    My application locks a QMutex into a try catch statment. The problem is that if an exception is raised, I don't know if the mutex is locked or not, and if I call "unlock" I get an application crash with a message like "a mutex must be unlocked in the same thread that locked it".
    QMutex class don't provide any method to know if it is locked.

    A solution could be to declare a boolean variable to use it as "mutex_locked" ?

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Jan 2007
    Posts
    30
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    MacOS X

    Default Re: Mutex unlock without locking it

    http://doc.qt.nokia.com/4.7/qmutexlocker.html

    Use a QMutexLocker, within the scope of the method, to lock it.
    When it goes out of scope, the QMutexLocker is destroyed and the mutex is unlocked.

  3. The following user says thank you to igor for this useful post:

    ^NyAw^ (23rd September 2010)

Similar Threads

  1. QFileDialog in modeless QDialog and mutex error
    By enno in forum Qt Programming
    Replies: 2
    Last Post: 7th April 2010, 21:49
  2. Thread mutex lock and return value
    By ^NyAw^ in forum Qt Programming
    Replies: 5
    Last Post: 13th February 2010, 08:32
  3. Qthread mutex
    By dognzhe in forum Qt Programming
    Replies: 5
    Last Post: 18th May 2009, 06:46
  4. QDirectPainter::unlock () implemented?
    By TTGator in forum Qt Programming
    Replies: 0
    Last Post: 20th November 2008, 21:40
  5. locking the combobox
    By jayw710 in forum Qt Programming
    Replies: 5
    Last Post: 10th May 2006, 17:12

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.