diff options
author | Kari Oikarinen <kari.oikarinen@qt.io> | 2019-10-07 12:15:09 +0300 |
---|---|---|
committer | Kari Oikarinen <kari.oikarinen@qt.io> | 2019-11-01 10:09:43 +0300 |
commit | 2d680b27f3c56aacbec3191f38b7b1898c8747b1 (patch) | |
tree | fb1eddc500c0f421b812e097b87225c9b6921119 /src/network/socket/qlocalsocket.cpp | |
parent | 26f9cb7ce5a81eac9743d0dd183f59ceb7e73569 (diff) |
Clarify Q{Abstract,Local}Socket::waitForDisconnected() documentation
Make it clear that the functions will return false if the socket was already
disconnected.
Fix the QLocalSocket example snippet to handle that case correctly by checking
state() before attempting to wait.
Fixes: QTBUG-50711
Change-Id: I4ab4062446a0041a35a3a1d65a19202ffa103298
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network/socket/qlocalsocket.cpp')
-rw-r--r-- | src/network/socket/qlocalsocket.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp index 1c34cd13ee..af7cdb76d2 100644 --- a/src/network/socket/qlocalsocket.cpp +++ b/src/network/socket/qlocalsocket.cpp @@ -287,11 +287,12 @@ QT_BEGIN_NAMESPACE /*! \fn bool QLocalSocket::waitForDisconnected(int msecs) - Waits until the socket has disconnected, up to \a msecs - milliseconds. If the connection has been disconnected, this - function returns \c true; otherwise it returns \c false. In the case - where it returns \c false, you can call error() to determine - the cause of the error. + Waits until the socket has disconnected, up to \a msecs milliseconds. If the + connection was successfully disconnected, this function returns \c true; + otherwise it returns \c false (if the operation timed out, if an error + occurred, or if this QLocalSocket is already disconnected). In the case + where it returns \c false, you can call error() to determine the cause of + the error. The following example waits up to one second for a connection to be closed: |