From 85a3e9880cacbb21e006da1358f22154351bd168 Mon Sep 17 00:00:00 2001 From: James Crook Date: Fri, 4 Oct 2019 11:31:23 +0100 Subject: [PATCH] Bug 2052 - Remove lock file, even if read only The line breaks in the second message are also changed. They are not changed in the first message, as that message is already translated. --- src/AudacityApp.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index dcf5d65d2..ba4e8fa82 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -1902,22 +1902,25 @@ bool AudacityApp::CreateSingleInstanceChecker(const wxString &dir) #ifdef __WXMAC__ // Bug 2052 // On mac, the lock file may persist and stop Audacity starting properly. - wxString lockFileName = dir + "/" + name; - int action = AudacityMessageBox(wxString::Format( _("If you're sure another copy of Audacity isn't running, Audacity\ncan skip the test for 'Audacity already running' next time\nby removing the lock file:\n\n%s\n\nDo you want to do that?"), - lockFileName - ), - _("Possible Lock File Problem"), - wxYES_NO | wxICON_EXCLAMATION, - NULL); - if (action == wxYES){ - ::wxRemoveFile( lockFileName ); + auto lockFileName = wxFileName(dir,name); + bool bIsLocked = lockFileName.IsOk() && lockFileName.FileExists(); + if( bIsLocked ){ + int action = AudacityMessageBox(wxString::Format( _("If you're sure another copy of Audacity isn't\nrunning, Audacity can skip the test for\n'Audacity already running' next time\nby removing the lock file:\n\n%s\n\nDo you want to do that?"), + lockFileName.GetFullName() + ), + _("Possible Lock File Problem"), + wxYES_NO | wxICON_EXCLAMATION, + NULL); + if (action == wxYES){ + // If locked, unlock. + lockFileName.SetPermissions( wxS_DEFAULT ); + ::wxRemoveFile( lockFileName.GetFullName() ); + } } #endif return false; } - - #if defined(__WXMSW__) // Create the DDE IPC server mIPCServ = std::make_unique(IPC_APPL);