KDialog errors appear in FileChooser result path


#1

Hi,

I’m running Arch Linux x64 (fully updated) with KDE 4.10 and juce HEAD. I’ve stumbled across some unexpected behaviour, namely with FileChooser and the path of the resulting file. Here’s the code:

            FileChooser fc("Select a file", File("/home/francois"));
            if(!fc.browseForFileToOpen())
                return;

            File result(fc.getResult());
            Log::write("PRINTING OF result.getFullPathName() :");
            Log::write(result.getFullPathName());
            Log::write("END OF PRINTING");

This results in the following:

The code causing this is in juce_linux_FileChooser.cpp in the showPlatformDialog function. Searching the forum, this code is taken from the following thread: http://www.rawmaterialsoftware.com/viewtopic.php?f=5&t=9975&hilit=kdialog . As can be seen from the terminal output the selected file is actually there, only it’s on the last line. The errors above it are from KDialog. When running the application as root, there is no problem - KDialog doesn’t output these errors then.

I’m not sure what’s the best way to solve it. For now I’ll just use the FileChooserDialogBox which works perfectly fine, but this issue requires some attention nonetheless.

Thanks! :smiley:

EDIT: Redirecting stderr to /dev/null would work I think, but haven’t found out how to do this with any of the classes (Process/ChildProcess)


#2

Damn, that’s annoying! Perhaps there’s a command-line setting that would put it into silent mode?


#3

No such option for kdialog…

The errors are written to stderr and the ChildProcess::readAllProcessOutput function also reads that. If we could redirect stderr to /dev/null or somehow only read stdout then that would solve the problem I think.


#4

Latest Tracktion linux release have this issue, making file-dialogs competely unusable in KDE.

 

There's a quick&easy workaround. Instead of this:

kdialog --getopenfilename .

use this:

kdialog --getopenfilename . 2>/dev/null

That will get stderr to /dev/null, and we only get the final proper filename in the end.

(Thanks francoisvdv for the suggestion!)

 

It would be better to implement catching stderr directly in the code, but for now this works.

 


#5

Neat suggestion! I've not got time to test this right now, but I guess adding this line to juce_linux_FileChooser.cpp at line 95:


        args.add (startPath);
        args.add ("2>/dev/null");
    }
    else

..would work?


#6

fixed in http://www.juce.com/forum/topic/assert-hit-when-using-native-file-dialogs