Skip to content

Commit ed18965

Browse files
committed
Do not increment created_documents flag when failed to open
1 parent 0878d2d commit ed18965

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/Application.vala

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ public class Application : Gtk.Application {
8989
print (unsaved_doc);
9090
string path = Path.build_filename (data_dir_path, unsaved_doc);
9191
File file = File.new_for_path (path);
92-
open_file (file);
92+
93+
bool ret = open_file (file);
94+
if (!ret) {
95+
continue;
96+
}
97+
9398
created_documents++;
9499
}
95100

@@ -160,15 +165,16 @@ public class Application : Gtk.Application {
160165

161166
}
162167

163-
public void open_file (File file) {
164-
if (file.query_file_type (FileQueryInfoFlags.NONE) == FileType.REGULAR) {
165-
var new_window = new AppWindow (file);
166-
add_window (new_window);
167-
new_window.present ();
168-
} else {
168+
public bool open_file (File file) {
169+
if (file.query_file_type (FileQueryInfoFlags.NONE) != FileType.REGULAR) {
169170
warning ("Couldn't open, not a regular file.");
171+
return false;
170172
}
171173

174+
var new_window = new AppWindow (file);
175+
add_window (new_window);
176+
new_window.present ();
177+
return true;
172178
}
173179

174180
public void on_open_document () {

0 commit comments

Comments
 (0)