summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp19
-rw-r--r--src/organizercore.cpp21
-rw-r--r--src/organizercore.h4
3 files changed, 32 insertions, 12 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index c3a19bf4..fc766af6 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -2129,11 +2129,20 @@ void MainWindow::activateProxy(bool activate)
busyDialog.setWindowFlags(busyDialog.windowFlags() & ~Qt::WindowContextHelpButtonHint);
busyDialog.setWindowModality(Qt::WindowModal);
busyDialog.show();
- QFuture<void> future = QtConcurrent::run(MainWindow::setupNetworkProxy, activate);
- while (!future.isFinished()) {
- QCoreApplication::processEvents();
- ::Sleep(100);
- }
+
+ QFutureWatcher<void> futureWatcher;
+ QEventLoop loop;
+ connect(&futureWatcher, &QFutureWatcher<void>::finished,
+ &loop, &QEventLoop::quit,
+ Qt::QueuedConnection);
+
+ futureWatcher.setFuture(
+ QtConcurrent::run(MainWindow::setupNetworkProxy, activate)
+ );
+
+ // wait for setupNetworkProxy while keeping ui responsive
+ loop.exec();
+
busyDialog.hide();
}
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 14f85ac0..efb98cca 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -1471,6 +1471,8 @@ void OrganizerCore::directory_refreshed()
refreshLists();
}
+ emit directoryStructureReady();
+
log::debug("refresh done");
}
@@ -1768,9 +1770,12 @@ bool OrganizerCore::beforeRun(
{
saveCurrentProfile();
- while (m_DirectoryUpdate) {
- ::Sleep(100);
- QCoreApplication::processEvents();
+ // need to wait until directory structure is ready
+ if (m_DirectoryUpdate) {
+ QEventLoop loop;
+ connect(this, &OrganizerCore::directoryStructureReady, &loop, &QEventLoop::quit,
+ Qt::ConnectionType::QueuedConnection);
+ loop.exec();
}
// need to make sure all data is saved before we start the application
@@ -1838,10 +1843,12 @@ ProcessRunner::Results OrganizerCore::waitForAllUSVFSProcesses(
std::vector<Mapping> OrganizerCore::fileMapping(const QString &profileName,
const QString &customOverwrite)
{
- // need to wait until directory structure
- while (m_DirectoryUpdate) {
- ::Sleep(100);
- QCoreApplication::processEvents();
+ // need to wait until directory structure is ready
+ if (m_DirectoryUpdate) {
+ QEventLoop loop;
+ connect(this, &OrganizerCore::directoryStructureReady, &loop, &QEventLoop::quit,
+ Qt::ConnectionType::QueuedConnection);
+ loop.exec();
}
IPluginGame *game = qApp->property("managed_game").value<IPluginGame *>();
diff --git a/src/organizercore.h b/src/organizercore.h
index 00765694..81119866 100644
--- a/src/organizercore.h
+++ b/src/organizercore.h
@@ -371,6 +371,10 @@ signals:
void close();
+ // Notify that the directory structure is ready to be used on the main thread
+ // Use queued connections
+ void directoryStructureReady();
+
private:
void saveCurrentProfile();