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 347883 - do-overwrite-confirmation does nothing in 2.10
do-overwrite-confirmation does nothing in 2.10
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
2.10.x
Other Linux
: High major
: ---
Assigned To: Federico Mena Quintero
Federico Mena Quintero
: 351063 352768 (view as bug list)
Depends on:
Blocks: 436242
 
 
Reported: 2006-07-18 08:10 UTC by Michael Natterer
Modified: 2011-02-04 16:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
347883-minimal.diff (512 bytes, patch)
2007-05-30 19:27 UTC, Mathias Hasselmann (IRC: tbf)
none Details | Review
347883-complete.diff (1.20 KB, patch)
2007-05-30 19:28 UTC, Mathias Hasselmann (IRC: tbf)
accepted-commit_now Details | Review
testcase.c (1.13 KB, text/x-csrc)
2007-05-30 19:47 UTC, Mathias Hasselmann (IRC: tbf)
  Details

Description Michael Natterer 2006-07-18 08:10:19 UTC
See summary. Setting priority to high because it can cause data loss.
Comment 1 Federico Mena Quintero 2006-07-19 16:30:34 UTC
Indeed.  I now have a test for this in autotestfilechooser; I'll have a fix ready soon.
Comment 2 Federico Mena Quintero 2006-08-14 16:38:39 UTC
*** Bug 351063 has been marked as a duplicate of this bug. ***
Comment 3 Luca Bruno 2006-08-20 01:47:59 UTC
It seems to work fine here Gtk 2.10.1
Comment 4 Gustavo Carneiro 2006-08-20 10:23:23 UTC
Luca, see bug 351063.
Comment 5 Gustavo Carneiro 2006-08-25 10:41:11 UTC
*** Bug 352768 has been marked as a duplicate of this bug. ***
Comment 6 Kristian Rietveld 2006-09-13 12:13:44 UTC
This should work fine in most cases with the latest gtk+ release.  There's one known problem though: if the user calls gtk_dialog_response() (again) from the response callback, the overwrite confirmation isn't run (because gtk_file_chooser_default_should_respond) isn't called.  This is probably a valid use of the API and should be fixed at some point (might have to rework the thing without using response-requested?)
Comment 7 Michael Natterer 2007-01-20 21:22:16 UTC
I'd say this is definitely a valid use of the API since it's the *only*
way of allowing entering filenames without extensions. You can do that
in many apps, and the apps simply append the extension in their
response() callbacks. The only way of getting the changed filename
properly checked is running response() again.
Comment 8 Federico Mena Quintero 2007-01-25 21:08:20 UTC
We shouldn't allow recursion in ::response.  Mitch, what you really want is robust support for multiple file types and extensions in the chooser.  That's bug #135901.

Does this bug still happen, modulo the ::response thing?
Comment 9 Michael Natterer 2007-01-26 09:54:28 UTC
I suppose a file type menu as in bug #135901 would have a "by extension"
entry and that would be active by default? Or would the menu follow the
user entering "foo.gif" even though the menu says "PNG"?

The problem here is that if you enter a filename without extension,
*and* no file type is selected from the menu, most apps would probably
want to save as their default file format, so GIMP appends ".xcf"
and just wants to run the overwrite-confirm logic again.

I don't see what's the problem with allowing to recurse in resoponse.
It did work absolutely fine in 2.8, so this is clearly a regression
that sould be fixed.
Comment 10 Federico Mena Quintero 2007-01-30 02:19:22 UTC
(In reply to comment #9)
> I suppose a file type menu as in bug #135901 would have a "by extension"
> entry and that would be active by default? Or would the menu follow the
> user entering "foo.gif" even though the menu says "PNG"?

I don't know; that's why the API / user interface for file types is not designed yet :)

> The problem here is that if you enter a filename without extension,
> *and* no file type is selected from the menu, most apps would probably
> want to save as their default file format, so GIMP appends ".xcf"
> and just wants to run the overwrite-confirm logic again.

In this case I would probably add a signal like "give-me-the-filename-plus-the-default-extension" that gets run *before* checking for overwrites.  Or something like that.  But it needs to be designed to fit well in the overall picture.

> I don't see what's the problem with allowing to recurse in resoponse.
> It did work absolutely fine in 2.8, so this is clearly a regression
> that sould be fixed.

If this were a normal regression I would agree, but I definitely don't think we should support recursing in ::response.

I don't know if there's an easy way to allow this, given the async nature of the checks for files.
Comment 11 Michael Natterer 2007-05-06 17:55:20 UTC
Very well, I moved the second call to ::response to an idle function
(not recursive any more), and it still does nothing. There is simply
no way of delaying the second response call enough to have the file
chooser catch up with its internal state. On second call (with appended
extension) it simply overwrites the file without any warning.

I call this a *severe* regression, just saying "this is not allowed
any more" doesn't help a bit.
Comment 12 Mathias Hasselmann (IRC: tbf) 2007-05-30 19:27:31 UTC
Created attachment 89066 [details] [review]
347883-minimal.diff

The problem is that GtkFileChooserDialog forgets to reset its internal response_requested flag, once the response triggered by file_chooser_widget_response_requested has been processed.

This patch contains the minimal changes needed to make the bug disappear.
Comment 13 Mathias Hasselmann (IRC: tbf) 2007-05-30 19:28:55 UTC
Created attachment 89067 [details] [review]
347883-complete.diff

This patch is slightly more intrusive as I believe that response_requested should be reset everytime a response is received.
Comment 14 Mathias Hasselmann (IRC: tbf) 2007-05-30 19:47:40 UTC
Created attachment 89069 [details]
testcase.c
Comment 15 Kristian Rietveld 2007-05-30 20:36:56 UTC
Very good catch.  I think the patch is right, though I am not 100% sure if we should reset response_requested if !response_matters.  Maybe it should, since response_requested is used to probably only ignore the "stop emission condition" once (for a response that matters?).

It would probably be good to get that testcase converted to something that works automatically and get it integrated in autotestfilechooser.


I hope either federico or matthias can also closely look at the patch since this is all pretty confusing and then give approval.


Mitch, the testcase seems to be equivalent to gimp's behavior *before* you changed it to call response from and idle.  Does this patch also fix the case where gimp calls response from idle?  (I think it does, but would be good if you could quickly test).

Comment 16 Michael Natterer 2007-05-31 08:34:07 UTC
The patch seems to work perfectly :-) And actually it even fixes the
original GIMP code that calls response recursively from the response
callback without any idle.

(when applying please note that both trun and 2-10 have this bug)
Comment 17 Matthias Clasen 2007-05-31 17:14:21 UTC
I'm not going to be of much use here, either trust your and mitch's judgement, or get federico to comment...
Comment 18 Federico Mena Quintero 2007-05-31 20:28:26 UTC
Comment on attachment 89067 [details] [review]
347883-complete.diff

Please commit to trunk and the stable branches.  Thanks for debugging this, Mathias :)

Is it possible to integrate the test into autotestfilechooser?
Comment 19 Mathias Hasselmann (IRC: tbf) 2007-05-31 22:25:01 UTC
Commited to trunk and 2.10 branch. You said stable branch__es__. So which other branches shall see the patch? The test is integrated into autotestfilechooser on trunk.
Comment 20 Matthias Clasen 2007-05-31 22:29:50 UTC
trunk and 2.10 is all there is, thanks.