From d425f9b49ad4f0b93830ac81a89df81abcec6a6f Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Fri, 17 Jun 2022 17:30:46 +0200 Subject: give each thread a string, require UI Thread to clear string to progress --- src/qt/workers.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/qt/workers.cpp') diff --git a/src/qt/workers.cpp b/src/qt/workers.cpp index 3fce706..8eb26df 100644 --- a/src/qt/workers.cpp +++ b/src/qt/workers.cpp @@ -14,7 +14,7 @@ struct thread_object_info { int working; - QString* infoText; + QString infoText; char* of_dir; char* remote; struct revision_t* rev; @@ -26,7 +26,6 @@ static void* thread_download(void* pinfo) struct thread_object_info* info = (struct thread_object_info*)pinfo; if (info) { - QString* infoText = info->infoText; char* of_dir = info->of_dir; char* remote = info->remote; struct revision_t* rev = info->rev; @@ -35,10 +34,10 @@ static void* thread_download(void* pinfo) struct file_info* file = &rev->files[i]; if (file->type == TYPE_WRITE) { - *info->infoText = QString("Verifying %1").arg(file->object); + info->infoText = QString("Verifying %1").arg(file->object); if (verifyFileHash(of_dir, file)) { - *infoText = QString("Downloading %1").arg(file->object); + info->infoText = QString("Downloading %1").arg(file->object); downloadObject(of_dir, remote, file); } } @@ -132,23 +131,24 @@ int Worker::update_setup(int local_rev, int remote_rev) pthread_t* thread = &download_threads[tindex]; struct thread_object_info* info = &thread_info[tindex]; - QString* threadString = &infoStrings[tindex]; + QString* threadString = &info->infoText; if (!threadString->isEmpty()) { infoText = *threadString; emit resultReady(RESULT_UPDATE_TEXT); + + // allow the main thread to clear the string before we continue + while (!infoText.isEmpty() && do_work) {}; } info->working = 1; - info->infoText = threadString; info->of_dir = of_dir; info->remote = remote; info->rev = rev; info->index = i; progress = (int)(((i * 100) + 1) / rev->file_count); - emit resultReady(RESULT_UPDATE_TEXT); pthread_create(thread, NULL, thread_download, info); } -- cgit v1.2.3