KTcpSocket + errorString()

Martin Koller kollix at aon.at
Sat Sep 12 23:31:58 BST 2009


Hi,

I'm looking into the problem why a kio (POP, IMAP) slave connectToHost / 
waitForConnected() and having no connect (==timeout) always shows "Unknown 
Error" in the Error Dialog, whereby QTcpSocket has a SocketTimeoutError in 
that case.

The problem seems to be due to KTcpSocket internally having another Socket 
class, but being itself an QIODevice but not synchronizing the errorString 
between its socket and itself.

Is the proposed patch ok ?

Index: ktcpsocket.cpp
===================================================================
--- ktcpsocket.cpp      (Revision 1020053)
+++ ktcpsocket.cpp      (Arbeitskopie)
@@ -612,6 +612,8 @@
 bool KTcpSocket::waitForConnected(int msecs)
 {
     bool ret = d->sock.waitForConnected(msecs);
+    if (!ret)
+        setErrorString(d->sock.errorString());
     setOpenMode(d->sock.openMode() | QIODevice::Unbuffered);
     return ret;
 }
@@ -620,6 +622,8 @@
 bool KTcpSocket::waitForDisconnected(int msecs)
 {
     bool ret = d->sock.waitForDisconnected(msecs);
+    if (!ret)
+        setErrorString(d->sock.errorString());
     setOpenMode(d->sock.openMode() | QIODevice::Unbuffered);
     return ret;
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20090913/3a17cde7/attachment.sig>


More information about the kde-core-devel mailing list