Results 1 to 2 of 2

Thread: QWaitCondition

  1. #1
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QWaitCondition

    Hi,
    I had a code in Qt-3.2. its like this,

    QWaitCondition m_CaptureFinished;

    if (running()) {
    qDebug("Waiting for capture thread to stop...");
    m_StopCapture = true;
    m_CaptureFinished.wait();
    qDebug("Capture thread stopped.");
    }

    and this section is working in Qt-3.2. But When I try this code then it display an error like this
    error: no matching function for call to ‘QWaitCondition::wait()’
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qwaitcondition.h:44: note: candidates are: bool QWaitCondition::wait(QMutex*, long unsigned int)

    Then I try like this

    if (isRunning()) {
    m_BufMutex.lock();
    qDebug("Waiting for capture thread to stop...");
    m_StopCapture = true;
    m_CaptureFinished.wait(&m_BufMutex);
    qDebug("Capture thread stopped.");
    }

    Then doesn't display any error when I make the program. But at run time the program is crashed due to the thread is not stoped. How can I solve this ploblem.
    Please help me.....

  2. #2
    Join Date
    Oct 2007
    Location
    Munich, Bavaria
    Posts
    144
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question Re: QWaitCondition

    It's hard to tell, whats going on in your program.
    We need to see the code piece calling wakeOne() or wakeAll().
    Maybe you have some deadlock situation.

    One thing making me wonder is:
    In your example you never call m_BufMutex.unlock().

    Good luck,

    Tom

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.