From 837d5e18f34c3c882cb4a860bf6cc9ad5f658f02 Mon Sep 17 00:00:00 2001 From: Steve Daulton Date: Sun, 29 Apr 2018 21:03:13 +0100 Subject: [PATCH] Fix Audacity failing silently on new instance Should now behave the same on Linux as on Windows. --- src/AudacityApp.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 2e1a261ec..42da742d3 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -1903,14 +1903,22 @@ bool AudacityApp::CreateSingleInstanceChecker(const wxString &dir) sock->Connect(addr, true); if (sock->IsConnected()) { - for (size_t i = 0, cnt = parser->GetParamCount(); i < cnt; i++) + if (parser->GetParamCount() > 0) { - // Send the filename - wxString param = parser->GetParam(i); - sock->WriteMsg((const wxChar *) param, (param.Len() + 1) * sizeof(wxChar)); + for (size_t i = 0, cnt = parser->GetParamCount(); i < cnt; i++) + { + // Send the filename + wxString param = parser->GetParam(i); + sock->WriteMsg((const wxChar *) param, (param.Len() + 1) * sizeof(wxChar)); + } + } + else + { + // Send an empty string to force existing Audacity to front + sock->WriteMsg(wxEmptyString, sizeof(wxChar)); } - return false; + return sock->Error(); } wxMilliSleep(100);