Quote Originally Posted by miwarre View Post
Thanks wysota.

This leaves open the initial issue: how do you cancel/interrupt/terminate/kill/... connectToHost() ?

This is even more needed as connectToHost() in many cases does not seem to time-out at all...

Miwarre

P.S.: what you say matches what is actually happening, but it was not evident from the documentation, which seems to state that abort() can abort any command, in some cases by also sending ABORT to the server:

Thanks again, miwarre
Hi, if You still dwell on that or someone else is looking for information on this problem. Probably, Your application crashes, because You use delete operator on the QFtp instance. In this case, if there was something posted, sent to this object, or signal invoked, there is possibility, it will crash. Instead, try using QObject::deleteLater(), which causes that instance is deleted just at the end of the QEventLoop.

It worked in my case. I worked with ftp server that run on the machine which could get disconnected and, what is worse, restared after being disconnected. Thus, I still had connection opened, and couldn't work on the QFtp instance any more. The timeout signal (see class FtpWatcher in this thread, hopefully correct one) was connected to the slot, which invoked:
Qt Code:
  1. ftp->abort();
  2. ftp->close();
  3. ftp->deleteLater();
  4. ftp->new QFtp();
To copy to clipboard, switch view to plain text mode 

Probably it wasn't necessary to call first two functions, but I tried to be safe (If by miracle connection got back - but probably then, I wouldn't manage to wait for it to be closed before destruction). Hopefully it helps somenone.

All the best,
Chris.