From e92749e7cafe138e3d5b3c074e1c71a5f6e11b1a Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 15 Jul 2020 17:09:01 +0100 Subject: [PATCH] Linux: Fixed a bug in detecting which native file browser to use on Manjaro where `which` returns a non-empty string on failure and fixed a bug in zenity wildcard args --- .../native/juce_linux_FileChooser.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp b/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp index 780716a80d..9e8251546c 100644 --- a/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp @@ -26,14 +26,19 @@ namespace juce { -static bool exeIsAvailable (const char* const executable) +static bool exeIsAvailable (String executable) { ChildProcess child; - const bool ok = child.start ("which " + String (executable)) - && child.readAllProcessOutput().trim().isNotEmpty(); - child.waitForProcessToFinish (60 * 1000); - return ok; + if (child.start ("which " + executable)) + { + auto output = child.readAllProcessOutput().trim(); + child.waitForProcessToFinish (60 * 1000); + + return output.isNotEmpty() && ! output.contains ("no " + executable); + } + + return false; } @@ -67,7 +72,7 @@ public: child.start (args, ChildProcess::wantStdOut); while (child.isRunning()) - if (! MessageManager::getInstance()->runDispatchLoopUntil(20)) + if (! MessageManager::getInstance()->runDispatchLoopUntil (20)) break; finish (false); @@ -217,8 +222,7 @@ private: StringArray tokens; tokens.addTokens (owner.filters, ";,|", "\""); - for (int i = 0; i < tokens.size(); ++i) - args.add ("--file-filter=" + tokens[i]); + args.add ("--file-filter=" + tokens.joinIntoString (" ")); } if (owner.startingFile.isDirectory())