Reusing FileChooserDialog causes wrong desensitisation of OK button + a pile-up of selection-changed events
Submitted by Daniel Boles
Created attachment 342460 MCVE
I'm having a strange issue with a FileChooserDialog that I reuse. Each time it gets run, it gets a new parent window, title, filter, and action set - and it also gets a suggested filename set. However, it doesn't seem to like this...
If such a FileChooserDialog has previously been run() with ACTION_LOAD, and I re-run it with ACTION_SAVE, the OK button (GTK_RESPONSE_OK or _ACCEPT) is sensitive but does nothing on click (the dialog keeps running). If I move the focus to another file, the button goes insensitive. If I then move it again, the button becomes sensitive and works as expected.
I'm not sure whether this depends on the call to set_filename, but if I leave that out, it just seems to do other weird things, so!
Attached is an MCVE. To reproduce, do the following:
- Create a file at /tmp/fakefile.txt
- Open this program
- "Load" the file using the provided button and clicking "Go" in the dialog.
- Now try to "Save" the file:
- you can't because the Go button is sensitive but does nothing
- you move to another file, and the button becomes insensitive
- you move back to fakefile.txt (or anything else), and finally the button works
I can presumably work around this by just constructing and destructing the dialog each time - and indeed, this is what I was doing before, before I thought I'd be clever and reuse it... - but that seems a bit like giving up! Something it seems GIMP and many other people did with various bugs around reusing this widget before: https://bugzilla.gnome.org/show_bug.cgi?id=702853 Ideally we can eventually get to the root of these problems rather than just sidestepping them.
Attachment 342460, "MCVE":