Results 1 to 8 of 8

Thread: QList::erase method does not work if I include an "emit signal" instruction

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QList::erase method does not work if I include an "emit signal" instruction

    Quote Originally Posted by d_stranz View Post
    When you emit a signal, you return control to the Qt event loop. If you do not emit any signal from within checkTimeouts(), then your loops run completely to the end and checkTimeouts() exits before control returns to the event loop. When you emit the signal, then all pending events will be processed, including any new timeouts
    No, that's not true, at least when a single execution thread is involved. The only way that the method is re-entered is that the signal is connected to a slot which calls this method again (e.g. emitTimeout() is connected to checkTimeouts()).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. The following user says thank you to wysota for this useful post:

    d_stranz (2nd May 2013)

  3. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,332
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    317
    Thanked 871 Times in 858 Posts

    Default Re: QList::erase method does not work if I include an "emit signal" instruction

    No, that's not true, at least when a single execution thread is involved. The only way that the method is re-entered is that the signal is connected to a slot which calls this method again (e.g. emitTimeout() is connected to checkTimeouts()).
    Yes, of course you're right, and my little qDebug() test would have proven me wrong. Blame it on coffee - either not enough or too much.

    So that seems to render my whole premise false; presuming that the OP isn't calling checkTimeouts() recursively, then why *does* emitting the signal cause the list to be improperly processed? Maybe one of the slots is also manipulating the list?

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QList::erase method does not work if I include an "emit signal" instruction

    Quote Originally Posted by d_stranz View Post
    then why *does* emitting the signal cause the list to be improperly processed?
    We don't know if the list is not processed correctly. We'd need to reproduce this errorneous behaviour which is not possible without a small compilable example. I'd start by disconnecting all the signals emitted from within emitTimeout() to see if the problem persists.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 27th January 2012, 17:29
  2. Why the signal "dataChanged" by QTableWidget not work?
    By Tao Clark in forum Qt Programming
    Replies: 1
    Last Post: 20th August 2011, 17:16
  3. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  4. Signal defined in "a.h" can not emit in "b.cpp"
    By Shawn in forum Qt Programming
    Replies: 9
    Last Post: 21st May 2007, 16:55
  5. Replies: 6
    Last Post: 3rd November 2006, 11:53

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
  •  
Qt is a trademark of The Qt Company.