Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Services/Document.vala
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ namespace Scratch.Services {
}
}

public bool closing { get; private set; default = false; }

public Gtk.Stack main_stack;
public Scratch.Widgets.SourceView source_view;
private Scratch.Services.SymbolOutline? outline = null;
Expand All @@ -181,7 +183,6 @@ namespace Scratch.Services {
private ulong onchange_handler_id = 0; // It is used to not mark files as changed on load
private bool loaded = false;
private bool mounted = true; // Mount state of the file
private bool closing = false;
private Mount mount;
private Icon locked_icon;

Expand Down Expand Up @@ -470,6 +471,9 @@ namespace Scratch.Services {

public async bool do_close (bool app_closing = false) {
debug ("Closing \"%s\"", get_basename ());
if (closing) {
return true;
}

if (!loaded) {
load_cancellable.cancel ();
Expand All @@ -488,7 +492,6 @@ namespace Scratch.Services {

// Ask whether to save changes
var parent_window = source_view.get_toplevel () as Gtk.Window;

var dialog = new Granite.MessageDialog (
_("Save changes to “%s” before closing?").printf (this.get_basename ()),
_("If you don't save, changes will be permanently lost."),
Expand Down Expand Up @@ -1155,6 +1158,9 @@ namespace Scratch.Services {
file.delete ();
return true;
} catch (Error e) {
if (e is IOError.NOT_FOUND) {
return true;
}
warning ("Cannot delete temporary file “%s”: %s", file.get_uri (), e.message);
}

Expand Down
4 changes: 4 additions & 0 deletions src/Widgets/DocumentView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ public class Scratch.Widgets.DocumentView : Gtk.Box {
// TabView tab events
tab_view.close_page.connect ((tab) => {
var doc = tab.child as Services.Document;
if (doc == null || doc.closing) {
return true; // doc.do_close () already called once
}

if (doc == null) {
tab_view.close_page_finish (tab, true);
} else {
Expand Down
Loading