After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 624136 - FileChooserButton changes path upon file modification
FileChooserButton changes path upon file modification
Status: RESOLVED WONTFIX
Product: pygtk
Classification: Bindings
Component: gtk
2.17.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
gnome[unmaintained]
Depends on:
Blocks:
 
 
Reported: 2010-07-12 07:17 UTC by Jason Heeris
Modified: 2018-08-17 13:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Demonstration script (645 bytes, application/octet-stream)
2010-07-12 07:17 UTC, Jason Heeris
Details

Description Jason Heeris 2010-07-12 07:17:26 UTC
Created attachment 165709 [details]
Demonstration script

Steps to reproduce:

1. Run the attached script
2. Select a file that is in a directory *with at least one other file*
3. Click "Check" to verify the path (prints to console)
4. Open the selected file in a text editor, modify it and save it
5. Click "Check" again

When I try this, the path has changed to the alphabetically previous file. I have not checked it with GTK+ in C.

This occurs under Debian with PyGTK 2.17.0, and under Windows with PyGTK built from Git (windows branch).

Originally posted on the pygtk list:

http://www.daa.com.au/pipermail/pygtk/2010-July/018803.html
Comment 1 Pietro Battiston 2010-07-12 13:07:47 UTC
Tobias Weber answers, on that same thread of the mailing list:

"No. It's very simple. Opinions on this are divided, but the fact is that most software doesn't change files, it creates a new one and moves it over the old one. So the file you selected ceases to exist, and therefore gets deselected. It doesn't matter that right after that another file with the same name appears."

I think the point is that nobody expects a filechooser, which the user interacts with to browse _paths_, and which returns again a _path_, to drop that level of abstraction, by memorizing internally some lower level file descriptors.

So while I could have in principle agreed for what concerns a call to "get_file", a call to "get_filename" should simply return the filename which the user has chosen.

_And in any case_, it shouldn't return some other random file, and I think that's what currently happens. So if what I say above is just crazy because the filechooser _has good reasons_ keep a GFile (?) instance internally, at least it should come back to the "unselected" state when that file "disappears".
Comment 2 Jason Heeris 2010-07-12 13:31:08 UTC
(In reply to comment #1)
> It doesn't matter that right after that another file with the same name
> appears."

I don't disagree with that (although I wasn't aware of that underlying behaviour). But the "just pick another arbitrary file" behaviour that is definitely unexpected.

If it's interesting, here's my use case. I have a UI where a user selects a hex file resulting from the compilation of some firmware. The firmware could be frequently recompiled as part of the normal workflow. So it needs to be reloaded (because another part of the UI shows a checksum generated from the file). I had a refresh button that would reload the file, but it kept getting the wrong file.

Clearly the solution is to simply get the path when the 'file-set' signal is emitted and store it in my code (instead of getting it on demand from the widget itself).

(Actually, I would have been happy if the docs simply said — loudly — "this widget makes no guarantees that the path you get when it emits the 'file-set' signal will remain the same later.")

> _And in any case_, it shouldn't return some other random file, and I think
> that's what currently happens. So if what I say above is just crazy because the
> filechooser _has good reasons_ keep a GFile (?) instance internally, at least
> it should come back to the "unselected" state when that file "disappears".

Well... maybe. It doesn't have to go "unselected," you could say that the programmer should deal with the usual problems that might crop up in later code if the file is missing. I mean, the file could go missing between the user choosing the file and the code doing something with it.

IMO, ideally, the path would stay the same. The file chooser button is a user activated widget, and should not change state because of external forces that the user might not have control over (or does, but indirectly).
Comment 3 John Stowers 2010-07-13 01:06:24 UTC
I'm almost certain that if this is bug-worthy then this is a gtk+ problem.
Comment 4 André Klapper 2018-08-17 13:40:37 UTC
pygtk is not under active development anymore and had its last code changes
in 2013. Its codebase has been archived:
https://gitlab.gnome.org/Archive/pygtk/commits/master

PyGObject at https://gitlab.gnome.org/GNOME/pygobject is its successor. See https://pygobject.readthedocs.io/en/latest/guide/porting.html for porting info.

Closing this report as WONTFIX as part of Bugzilla Housekeeping to reflect
reality. Feel free to open a task in GNOME Gitlab if the issue described in this task still applies to a recent version of PyGObject. Thanks!