Results 1 to 2 of 2

Thread: QtSocket readyRead and exception

  1. #1
    Join Date
    Sep 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QtSocket readyRead and exception

    Hi.

    If you are processing a readyRead slot and new information is received, you will not be inform about it. It looks logical...

    http://stackoverflow.com/questions/1...cant-be-missed


    Is it possible that an exception thrown inside of readyRead slot, and captured on QApplication::notify the socket thinks my application continues inside readyRead slot?

    To solve it, I only need to add a try catch on readyRead slot.

    It looks confusing and not enough documented.


    I suppose, that Qt cannot manage the situation because the slot could be thrown to a different thread. Is that right?



    kind regards

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QtSocket readyRead and exception

    Quote Originally Posted by joseluis View Post
    Hi.

    If you are processing a readyRead slot and new information is received, you will not be inform about it. It looks logical...

    http://stackoverflow.com/questions/1...cant-be-missed
    Are you certain that the problem mentioned in the thread you linked to actually exists? Have you run into it? I have always assumed that all I had to do was read all the available data before exiting readyRead(), and I have never faced such an issue doing so.

    Quote Originally Posted by joseluis View Post
    Is it possible that an exception thrown inside of readyRead slot, and captured on QApplication::notify the socket thinks my application continues inside readyRead slot?

    To solve it, I only need to add a try catch on readyRead slot.

    It looks confusing and not enough documented.
    You must not let an exception propagate outside a slot whose execution was triggered by Qt's signals and slots mechanism; see http://doc.qt.io/qt-5/exceptionsafet...nals-and-slots. Maybe the documentation does not put enough stress on this limitation.

    Quote Originally Posted by joseluis View Post
    I suppose, that Qt cannot manage the situation because the slot could be thrown to a different thread. Is that right?
    I am not aware of the reasons for this limitation, but supporting exceptions would raise--no pun intended--some non-trivial questions. E.g would the exception propagate to the caller for a direct connection, and outside the event loop executing the slot for a queued connection? This would break the locality of the component model offered by signals and slots. Besides, Qt's code would need to be exception-safe, which would probably significantly hurt performance.

Similar Threads

  1. Not getting readyRead from a QUdpSocket
    By evelBist in forum Newbie
    Replies: 3
    Last Post: 20th July 2010, 19:43
  2. QThread, signalling and readyRead()
    By kachofool in forum Newbie
    Replies: 9
    Last Post: 8th December 2009, 16:09
  3. readyRead problem
    By fruzzo in forum Qt Programming
    Replies: 11
    Last Post: 2nd September 2009, 19:50
  4. QExtSerialPort with readyRead()
    By tho97 in forum Qt Programming
    Replies: 4
    Last Post: 27th August 2008, 20:18
  5. Question in readyRead(QTCPSOCKET)
    By morgana in forum Qt Programming
    Replies: 2
    Last Post: 24th July 2008, 18:11

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.