From 596032c42ff70bf78e5aa9d247a12d78eb1bcf8d Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 1 Dec 2020 21:17:12 -0500 Subject: [PATCH] Lift call to CreateSingleInstanceChecker out of InitTempDir --- src/AudacityApp.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index d29756ee3..39c2f1338 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -1269,6 +1269,17 @@ bool AudacityApp::OnInit() return false; } + // Make sure the temp dir isn't locked by another process. + { + auto key = + PreferenceKey(FileNames::Operation::Temp, FileNames::PathType::_None); + auto temp = gPrefs->Read(key); + if (temp.empty() || !CreateSingleInstanceChecker(temp)) { + FinishPreferences(); + return false; + } + } + //<<<< Try to avoid dialogs before this point. // The reason is that InitTempDir starts the single instance checker. // If we're waiitng in a dialog before then we can very easily @@ -1640,10 +1651,6 @@ bool AudacityApp::InitTempDir() FileNames::ResetTempDir(); FileNames::UpdateDefaultPath(FileNames::Operation::Temp, temp); - // Make sure the temp dir isn't locked by another process. - if (!CreateSingleInstanceChecker(temp)) - return false; - return true; }