External tool won't run if "Save" is set to "All documents"

Bug #1244338 reported by Ruud Koot
34
This bug affects 7 people
Affects Status Importance Assigned to Milestone
gedit
Fix Released
Medium
gedit (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Since upgrading to Ubuntu 13.10/gedit 3.8.3 external tools won't be run if the "Save" option is set to "All documents". If the setting it to "None" or "Current documents" then the tool will run again.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gedit (Ubuntu):
status: New → Confirmed
Revision history for this message
Kris (kristian-holsheimer) wrote :

I experience the same behavior as described above. I've also noticed that when the external tool is set to save "Current document", it doesn't actually save the current document upon being run.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. The issue you are reporting is an upstream one and it would be nice if somebody having it could send the bug to the developers of the software by following the instructions at https://wiki.ubuntu.com/Bugs/Upstream/GNOME. If you have done so, please tell us the number of the upstream bug (or the link), so we can add a bugwatch that will inform us about its status. Thanks in advance.

Changed in gedit (Ubuntu):
importance: Undecided → Low
Revision history for this message
andrew@drup.org (andrew-drup) wrote :

I'm getting exactly the problem that Kris reports above.
It seems that there is an inversion in the logic: If the document has *not* changed, then it saves it. If it has changed then it does not get saved.

Revision history for this message
andrew@drup.org (andrew-drup) wrote :

It looks like the bug was caused by this patch: https://bugzilla.gnome.org/show_bug.cgi?id=659437
I have created an account and posted comment #10
Here is my explanation of why the patch is broken:

This code is working in the opposite way it is intended to. I.e. only the
unchanged documents are being saved, and the changed documents are left
unsaved.
On inspecting the code, it is obvious why:

   if doc.get_modified():
       all_docs = False
       docs.remove(doc)

Modified documents are being removed from the list to be saved. Instead it
should be:

   if not doc.get_modified():

Revision history for this message
andrew@drup.org (andrew-drup) wrote :

I have filed a patch on bugzilla.
If you can't wait for the upstream fix to filter down, here is a script to apply it locally:
http://drup.org/gedit-external-tools-fails-save-documents

Revision history for this message
andrew@drup.org (andrew-drup) wrote :

Going through the code I figured out the problem that is that is causing save to fail when set to "All documents"--a classic Python bug.
If an item is deleted from a list while that list is being looped through, then it's like sawing off the branch of a tree you are sitting on. Here is the code:

    for i in range(len(docs)):
      doc = docs[i]
      ...
      docs.remove(doc)

The code will break with 'list index out of range' if a list member is deleted.

There is a simple fix--just reverse the direction of the loop:

    for i in reversed(range(len(docs))):

I have submitted a patch that fixes both errors. Please head over to https://bugzilla.gnome.org/show_bug.cgi?id=659437
and mark the bug "confirmed" if you are getting the error described in this bug report.

Revision history for this message
Kris (kristian-holsheimer) wrote :

I confirm that this fixes the problem, thanks!

Revision history for this message
andrew@drup.org (andrew-drup) wrote :

Please let's get this committed upstream.
Could you head over to https://bugzilla.gnome.org/show_bug.cgi?id=659437 (You'll have to create an account if you don't have one but this is a very quick process)

Just add a comment that says:
-You confirm the bug exisits
-This patch fixed it for you.
Thanks!

Revision history for this message
andrew@drup.org (andrew-drup) wrote :

Thanks Kris. The fix has been commited.

Revision history for this message
Sebastien Bacher (seb128) wrote :
Changed in gedit (Ubuntu):
status: Confirmed → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gedit - 3.10.4-0ubuntu2

---------------
gedit (3.10.4-0ubuntu2) trusty; urgency=medium

  * debian/patches/git_store_dialog.patch: tweaks to the save files dialog,
    give enough space to list several documents (lp: #988946)
  * debian/patches/git_save_run_tool_order.patch:
    - save the *modified* documents before running a tool (lp: #1244338)
 -- Sebastien Bacher <email address hidden> Mon, 10 Feb 2014 16:49:22 +0100

Changed in gedit (Ubuntu):
status: Fix Committed → Fix Released
Changed in gedit:
importance: Unknown → Medium
status: Unknown → New
Revision history for this message
andrew@drup.org (andrew-drup) wrote :

I can reproduce this very easily:

-Open two documents in gedit
-Change both of them
-run a script (external tool) that is marked to save just the current document

Both documents will be saved.

Changed in gedit:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.