diff options
| author | Al <26797547+Al12rs@users.noreply.github.com> | 2020-06-08 06:58:16 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-08 06:58:16 -0700 |
| commit | 4e0d47868ab78c58afca0733d3686c7dc3c6a4d9 (patch) | |
| tree | a2dcfe2de16b86bc88bdc99c8d912b8bb16d4807 /src/organizercore.cpp | |
| parent | ec5a78cefa610df153063c3cbfcc42b36998a542 (diff) | |
| parent | 67ae37d614b3afd9b9a54493fd496a4ea86aa2e9 (diff) | |
Merge pull request #1113 from Al12rs/bettr_wait_on_events
Use QEventLoop instead of manually calling ProcessEvents
Diffstat (limited to 'src/organizercore.cpp')
| -rw-r--r-- | src/organizercore.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
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 *>(); |
