Hello,
I have a file synchronisation class which is responsible to sync files between an local directory and a respository. Within this class I am downloading files.
The problem I am facing is, that the application seems to stop/hang in the event queue while the file is downloading (after that it is proceeding and works as usual).
I used the default setting for connect, Qt::AutoConnection which seems to use a QueuedConnection when used with threads to add it to the threads event loop.
The network is managed with QNetworkAccessManager (_nam).
Signals/slots for all the operations (within the downloader):
_reply = _nam->get(QNetworkRequest(url));
connect(_reply, SIGNAL(finished()), this, SLOT(httpFinished()));
connect(_reply, SIGNAL(readyRead()), this, SLOT(httpReadyRead()));
connect(_reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(httpDownloadProgress(qint64,qint64)));
_reply = _nam->get(QNetworkRequest(url));
connect(_reply, SIGNAL(finished()), this, SLOT(httpFinished()));
connect(_reply, SIGNAL(readyRead()), this, SLOT(httpReadyRead()));
connect(_reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(httpDownloadProgress(qint64,qint64)));
To copy to clipboard, switch view to plain text mode
I tried to shift the the class (fSync contains the downloader class) in another thread:
fSync = new FSyncClass();
fSync->moveToThread(_thread);
connect(_thread, SIGNAL(finished()), _thread, SLOT(deleteLater()));
connect(_thread, SIGNAL(finished()), fSync, SLOT(deleteLater()));
_thread->start();
fSync = new FSyncClass();
fSync->moveToThread(_thread);
connect(_thread, SIGNAL(finished()), _thread, SLOT(deleteLater()));
connect(_thread, SIGNAL(finished()), fSync, SLOT(deleteLater()));
_thread->start();
To copy to clipboard, switch view to plain text mode
GDB shows:
Main Thread-ID: 0xb6781000 //I call currentThreadId() to get this debug output within the main event loop
[New Thread 0xb674b450 (LWP 1254)] //gdb output
[New Thread 0xb5dff450 (LWP 1255)] //gdb output
[New Thread 0xb53ff450 (LWP 1256)] //gdb output
fSync Thread-ID: 0xb5dff450 //I call currentThreadId() to get this debug output within the class moved to the thread
Main Thread-ID: 0xb6781000 //I call currentThreadId() to get this debug output within the main event loop
[New Thread 0xb674b450 (LWP 1254)] //gdb output
[New Thread 0xb5dff450 (LWP 1255)] //gdb output
[New Thread 0xb53ff450 (LWP 1256)] //gdb output
fSync Thread-ID: 0xb5dff450 //I call currentThreadId() to get this debug output within the class moved to the thread
To copy to clipboard, switch view to plain text mode
So it seems like the class is really running in a separate thread.
I am running out of ideas and would appreciate any help.
Thank you in advance.
Bookmarks