diff options
Diffstat (limited to 'client/FileOpThread.cpp')
-rw-r--r-- | client/FileOpThread.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/client/FileOpThread.cpp b/client/FileOpThread.cpp index 42cb51b..3340db2 100644 --- a/client/FileOpThread.cpp +++ b/client/FileOpThread.cpp @@ -4,6 +4,13 @@ #include "FileOpThread.h" #include "UpdatedConfig.h" + +FileOpThread::~FileOpThread() +{ + if (downloadClient != NULL) + delete downloadClient; +} + void FileOpThread::run() { UpdatedConfig *cfg = UpdatedConfig::CurrentConfig(); @@ -51,13 +58,20 @@ void FileOpThread::run() if (files.size() != 0) { Logger::Debug("Setting server address to %s\n", cfg->GetServerAddr().c_str()); - QString addr = QString::fromLocal8Bit(cfg->GetServerAddr().c_str()); - DownloadClient downloadClient(addr); - downloadClient.Download(files); + downloadClient = new DownloadClient(addr); + + // start downloading files and + // wait for files to be downloaded + QEventLoop loop; + connect(downloadClient, SIGNAL(downloadFinished()), &loop, SLOT(quit())); + downloadClient->Download(files); + loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers); } else { Logger::Trace("No files to download from server.\n"); } -}
\ No newline at end of file + + Logger::Trace("Terminating Download Helper thread\n"); +} |