Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uigetfile and uiputfile return wrong directory with native file dialogs #51

Open
cyberkhalil opened this issue Mar 7, 2019 · 10 comments
Labels
flatpak This issue may be a problem in Flatpak itself help wanted Extra attention is needed

Comments

@cyberkhalil
Copy link

cyberkhalil commented Mar 7, 2019

hello , is it my problem or a bug in uigetfile()

uigetfile() returns my work path not the path for the file i choose.

documentation says about uigetfile() : Open a GUI dialog for selecting a
file and return the filename fname, the path to this file fpath, and the
filter index fltidx.

Octave version 5.1.0

>> [filename, folder] = uigetfile();
>> folder
folder = /home/khalil2535/Octave/HomeWork's/Homework1/
>> % selected file : /home/khalil2535/Octave/Materials/images/cameraman.tif
>> % my work path /home/khalil2535/Octave/HomeWork's/Homework1/

information about the environment :-
Operating System: Fedora 29
KDE Plasma Version: 5.14.5
Qt Version: 5.11.3
KDE Frameworks Version: 5.55.0
Kernel Version: 4.20.13-200.fc29.x86_64
OS Type: 64-bit

@cyberkhalil
Copy link
Author

cyberkhalil commented Mar 7, 2019

I installed octave using flatpak command line , i tried those maybe will be useful for tracking the problem ..

>> ls
"HomeWork's"   Materials
>> ls Materials/images/
cameraman.tif  lena_color_512.tif  mandril_gray.tif   woman_blonde.tif
>> pwd
ans = /home/khalil2535/Octave
>> file = fopen('/home/khalil2535/Octave/Materials/images/cameraman.tif');
>> file
file =  22
>>  is_valid_file_id(file)
ans = 1
>> img = imread('/home/khalil2535/Octave/Materials/images/cameraman.tif');
>> img(1)
ans = 156
>> imshow(img) % it shows the image correctly

@mtmiller
Copy link
Collaborator

mtmiller commented Mar 7, 2019

@khalil2535 Can you confirm that disabling the "Preferences" setting "Use native file dialogs" makes this work for you?

I can confirm this problem with native dialogs enabled (the default), and disabling native dialogs fixes it for me. This may be some flatpak containment problem with the native file dialog plugin.

@mtmiller
Copy link
Collaborator

mtmiller commented Mar 7, 2019

And btw I can confirm with GNOME, so this is not just about the KDE native dialog plugin.

@mtmiller mtmiller changed the title kde ui error uigetfile returns wrong directory with native file dialogs enabled Mar 7, 2019
@mtmiller
Copy link
Collaborator

mtmiller commented Mar 7, 2019

And this is specific to Flatpak, can not reproduce in a native build of Octave 5.1.0.

@cyberkhalil
Copy link
Author

@khalil2535 Can you confirm that disabling the "Preferences" setting "Use native file dialogs" makes this work for you?

I can confirm this problem with native dialogs enabled (the default), and disabling native dialogs fixes it for me. This may be some flatpak containment problem with the native file dialog plugin.

yes that what's happening with me , it works fine when i disable native file dialogs.

@mtmiller mtmiller changed the title uigetfile returns wrong directory with native file dialogs enabled uigetfile and uiputfile return wrong directory with native file dialogs Mar 7, 2019
@mtmiller
Copy link
Collaborator

mtmiller commented Mar 7, 2019

Same with uiputfile.

The uigetdir function behaves correctly.

@mtmiller
Copy link
Collaborator

mtmiller commented Mar 7, 2019

Looking at the Octave implementation of these functions, the FPATH output of uigetfile and uiputfile corresponds directly to the Qt QFileDialog::directory() method. This suggests that QFileDialog::directory() may not be returning the containing directory properly with native file dialogs via the Flatpak portal.

@mtmiller
Copy link
Collaborator

suggests that QFileDialog::directory() may not be returning the containing directory properly with native file dialogs via the Flatpak portal

I can confirm this with a trivial Qt program, not an Octave bug. Can someone who understands the Flatpak portal and permissions help out here?

@mtmiller mtmiller added help wanted Extra attention is needed flatpak This issue may be a problem in Flatpak itself labels Mar 14, 2019
@mtmiller mtmiller added help wanted Extra attention is needed and removed help wanted Extra attention is needed labels Apr 4, 2019
@mtmiller
Copy link
Collaborator

A simple example Qt project reproducing this behavior is here.

@mtmiller
Copy link
Collaborator

And I've reported this Qt bug: https://bugreports.qt.io/browse/QTBUG-77825

Based on my investigation so far, we may want to change Octave to not rely on the directory() method of the dialog, but instead only look at the full file name of the selected file(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flatpak This issue may be a problem in Flatpak itself help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants