Results 1 to 5 of 5

Thread: Using QEvent to avoid a slot to be called "concurrently"?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Using QEvent to avoid a slot to be called "concurrently"?

    Hello,

    in my application, I have to react to a specific signal by executing a slot. This slot can take some time to be executed, while multiple signals are often sent in a small amount of time. By putting some prints at the beginning and at the end of the slot, I noticed that in these cases the slot is called multiple times concurrently (but, as it appears, always in the same thread the receiver object lives in). This happens even if I use Qt::QueuedConnection in the connect() statements. I have to stop this and the force the second execution of the slot to wait for the first to be completed.

    So instead of emitting signals I tried posting events to the event queue of the receiver object. Here are the most important parts of this code: http://paste.chakra-project.org/2619/ . But again I face the same issue as before: further events do not wait for the first event handler's execution to be completed, and instead start a new instance of the function immediately. How can I solve this?

    Thanks for your time.
    Nondeterminism means never having to say you're wrong.

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: Using QEvent to avoid a slot to be called "concurrently"?

    Perhaps you could have a list or vector or whatever of your "things to do", from which you handle one at a time in a controlled manner. An added benefit of that would be a view to the amount of tasks stacking up.

  3. #3
    Join Date
    Apr 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Using QEvent to avoid a slot to be called "concurrently"?

    That's an idea, yes, I shall definitely use that if I'm not able to find other solutions
    Nondeterminism means never having to say you're wrong.

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using QEvent to avoid a slot to be called "concurrently"?

    "By putting some prints at the beginning and at the end of the slot, I noticed that in these cases the slot is called multiple times concurrently (but, as it appears, always in the same thread the receiver object lives in"

    Please show a compilable example that displays this behaviour. This should not be happening so either you are mistaken or there is something wrong with your application. I recall someone had a similar problem that seemed to be caused by using a third party library, although the real reason was not unearthed iirc.

    You should definitely find the cause and not work around it because you don't know what else could be going wrong.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Replies: 3
    Last Post: 20th June 2012, 23:21
  2. Replies: 3
    Last Post: 26th August 2011, 13:44
  3. How to avoid "warning: deprecated conversion from"?
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 18th January 2011, 15:11
  4. debugging "signal does not reach slot" in a template class
    By Daniel Dekkers in forum Qt Programming
    Replies: 1
    Last Post: 3rd April 2010, 16:03
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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.