Fixed regression that prevents app to quit if another process is already running

This commit is contained in:
emeric
2021-12-05 15:20:07 +01:00
parent 0cf6b2159e
commit 63ed28e38f
2 changed files with 9 additions and 5 deletions
@@ -223,13 +223,14 @@ namespace Recommendation
engine->load(forceReload, progressCallback ? progress : ProgressCallback {});
{
std::scoped_lock lock {_controlMutex};
_pendingEngines.erase(std::find(std::begin(_pendingEngines), std::end(_pendingEngines), engine.get()));
}
LMS_LOG(RECOMMENDATION, INFO) << "Initializing engine '" << engineTypeToString(engineType) << "': " << (_loadCancelled ? "aborted" : "complete");
}
{
std::scoped_lock lock {_controlMutex};
_pendingEngines.erase(std::find(std::begin(_pendingEngines), std::end(_pendingEngines), engine.get()));
}
if (!_loadCancelled)
{
std::unique_lock lock {_enginesMutex};
@@ -250,7 +251,9 @@ namespace Recommendation
LMS_LOG(RECOMMENDATION, DEBUG) << "Still " << _pendingEngines.size() << " pending engines!";
for (IEngine* engine : _pendingEngines)
{
engine->requestCancelLoad();
}
_pendingEnginesCondvar.wait(controlLock, [this] {return _pendingEngines.empty();});
_loadCancelled = false;