Results 1 to 5 of 5

Thread: Signals stops working

  1. #1
    Join Date
    Mar 2012
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Signals stops working

    I have a question: is there a maximun number of signals that can occur at the same moment?
    I found out the problem with QTcpSocket and QTimer (mostly).
    ex. when i get some messages at the same time (about 10, 10 signals readyRead is emitted) after that i dont get any signals from socket.
    Sometimes the same is happening with timer, it is working, in each second it emits timeout signal and sometimes it stops emiting (i checked the timer is still working but no timeout occurs)

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

    Default Re: Signals stops working

    yes, the maximum number of signals is 1 (per thread). That does not help you much because your question is poorly formed and does not address your actual problem. If you would like to divulge more information, perhaps you will get a more useful answer
    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.

  3. #3
    Join Date
    Mar 2012
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Signals stops working

    Thx for your fast reply
    So mayby from other side...
    I have class Reader which is working on QTcpSocket, it just read message when readyRead occure;
    After that, depends of message type, it emits other signal (emit mess, emit task etc)
    From another class Writer i just write message using the same socket.
    After sending some messages (lets say 10 x socket->write()) there are problems with Reader class (emit mess stops emiting when emit task works)
    Is it possible that Qt somehow blocks 1 signal from object and allows another one?
    (I also trying reconnecting signals/slots and blockSignals(true/false), nothing were able to reconnect "emit mess" signal)

  4. #4
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Signals stops working

    I don't know what you mean by maximum number of signals at same moment. In one thread, executions are happening one statement at time. So obviously signal is also one at one point of time at one instant.
    How slots are implemented after emitting signals depends on how slot was connected(Qt:irectConnection, QueuedConnection, etc).
    Normally, if in the same thread, the slot is executed immediately, If slot is in other thread, it is posted as event on thread of slot. In due time, it is executed(queuedConnection).
    Now with postedEvents like these, some get compressed, so 10 update() functions get compressed to just 1. However, not all, and certainly not your events are compressable.
    Qt Signal and Slot mechanism works. In single threaded or multithreaded applications.
    In multithreaded queued connections, underlying event system and qvariant system is used to queue the slot. paint events, move events, resize events, layout hint events, and language change events are compressible and can be missed if there are many at one loop of processevents. However, otherwise the events are not ignored even if the queue is flooded according to my knowledge.
    My advice is not to doubt the signal slot mechanism and look for problems elsewhere.

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

    Default Re: Signals stops working

    Quote Originally Posted by JaroMast View Post
    Thx for your fast reply
    So mayby from other side...
    I have class Reader which is working on QTcpSocket, it just read message when readyRead occure;
    After that, depends of message type, it emits other signal (emit mess, emit task etc)
    From another class Writer i just write message using the same socket.
    After sending some messages (lets say 10 x socket->write()) there are problems with Reader class (emit mess stops emiting when emit task works)
    Is it possible that Qt somehow blocks 1 signal from object and allows another one?
    (I also trying reconnecting signals/slots and blockSignals(true/false), nothing were able to reconnect "emit mess" signal)
    99.999% probability, problem is your code, not Qt. Time to get your debugger out.
    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. gdb stops working for Qt program ???
    By enno in forum Qt Programming
    Replies: 0
    Last Post: 27th February 2011, 12:47
  2. Replies: 1
    Last Post: 6th December 2010, 15:18
  3. Application stops working unexpectedly
    By baluk in forum Newbie
    Replies: 16
    Last Post: 20th November 2010, 15:06
  4. Signals not working in a QThread
    By curreli in forum Qt Programming
    Replies: 1
    Last Post: 10th August 2010, 16:04
  5. Trying to get basic signals example working
    By mrstephengross in forum Qt Programming
    Replies: 5
    Last Post: 27th February 2007, 19:58

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.