Linux nits


#1

(1) i think there is a compile guard missing in juce_amalgamated.cpp – when i comment out JUCE_USE_CDREADER in the amalgamated sources and .h :

#ifndef JUCE_USE_CDREADER
// #define JUCE_USE_CDREADER 1
#endif

then the compile breaks at line 258070 because the class is still being defined:

g++ -MMD -D “LINUX” -I “src” -I “/usr/include/freetype2” -O2 -o “obj/juce/Release/juce_amalgamated.o” -c "src/juce_amalgamated.cpp"
src/juce_amalgamated.cpp:258070: error: e$(B!Fe(BAudioCDReadere$(B!Ge(B has not been declared
src/juce_amalgamated.cpp:258070: error: ISO C++ forbids declaration of e$(B!Fe(BAudioCDReadere$(B!Ge(B with no type

it compiles if I wrap that code with this:

#if (JUCE_LINUX && JUCE_USE_CDREADER)
[…]
#endif

(2) launchInDefaultBrowser does not seem to work on file urls, eg urls that look like URL(“file:///Users/hkt/foo.html#bar”).launchInDefaultBrowser();

best,
–rick


#2

Ah - thanks for that, will tidy it up.

Interesting about the URL… I’ve not got my linux build handy for testing, but maybe just this, in juce_Linux_Files.cpp:

[code]bool juce_launchFile (const String& fileName,
const String& parameters) throw()
{
String cmdString (fileName);
cmdString << " " << parameters;

if (URL::isProbablyAWebsiteURL (fileName)
     || cmdString.startsWithIgnoreCase (T("file:"))
     || URL::isProbablyAnEmailAddress (fileName))
{
    // create a command that tries to launch a bunch of likely browsers
    const char* const browserNames[] = { "/etc/alternatives/x-www-browser", "firefox", "mozilla", "konqueror", "opera" };

    StringArray cmdLines;

    for (int i = 0; i < numElementsInArray (browserNames); ++i)
        cmdLines.add (String (browserNames[i]) + T(" ") + cmdString.trim().quoted());

    cmdString = cmdLines.joinIntoString (T(" || "));
}

const char* const argv[4] = { "/bin/sh", "-c", (const char*) cmdString.toUTF8(), 0 };

[/code]


#3

I believe calling xdg-open is a better replacement for /etc/alternatives/x-www-browser as it allows to open any document (pdf etc), and is less debian specific.

A warning also: the url is not escaped when the sh command is built, so calling juce_launchFile(T(“http://google.com”; xeyes"")) will have some funny side-effects. It would be safer to escape all dangerous characters, or to just avoid calling sh


#4

Thanks, I’d never heard of xdg-open. I guess I can just add it to that list as the first thing to attempt.

juce_launchFile isn’t supposed to be called directly, and the URL class should have sorted out the escape characters before it gets there. If I escaped them again in the launch code, you could end up with things getting double-escaped.


#5

A warning also: the url is not escaped when the sh command is built, so calling
juce_launchFile(T(“http://google.com”; xeyes"")) will have some funny
side-effects. It would be safer to escape all dangerous characters, or to just avoid calling sh

ahh. that explains the cryptic error message i see when i launch my app from the Terminal :

/bin/sh: ///home/hkt/Grace/3.4.0/doc/cm.html: Permission denied

ill try the workaround right now…


#6

OK that fixed it, thanks! FWIW im testing on ‘ubuntu studio’ and I do have xdg-open

–rick


#7