changeset 23905:b41792547237

fix editor behavior when files are externally changed/removed * file-editor-tab.cc (file_has_changed): new boolean paramter for closing the file, string parameter is used by signal from file system watcher and must not be used for closing the file * file-editor-tab.h: new boolean parameter for closing, per default false for the signals from the file system watcher
author Torsten <mttl@mailbox.org>
date Sun, 13 Aug 2017 00:33:25 +0200
parents 5c588c422e75
children 3b81ef7b562c
files libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h libgui/src/m-editor/file-editor.cc
diffstat 3 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Sat Aug 12 14:02:29 2017 -0700
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sun Aug 13 00:33:25 2017 +0200
@@ -2226,7 +2226,7 @@
 }
 
 void
-file_editor_tab::file_has_changed (const QString& do_close)
+file_editor_tab::file_has_changed (const QString&, bool do_close)
 {
   // Prevent popping up multiple message boxes when the file has
   // been changed multiple times by temporarily removing from the
@@ -2235,7 +2235,7 @@
   if (! trackedFiles.isEmpty ())
     _file_system_watcher.removePath (_file_name);
 
-  if (QFile::exists (_file_name) && do_close.isEmpty ())
+  if (QFile::exists (_file_name) && ! do_close)
     {
       // The file is modified
       if (_always_reload_changed_files)
@@ -2270,7 +2270,7 @@
     {
       // If desired and if file is not modified,
       // close the file without any user interaction
-      if (! do_close.isEmpty () && ! _edit_area->isModified ())
+      if (do_close && ! _edit_area->isModified ())
         {
           handle_file_resave_answer (QMessageBox::Cancel);
           return;
--- a/libgui/src/m-editor/file-editor-tab.h	Sat Aug 12 14:02:29 2017 -0700
+++ b/libgui/src/m-editor/file-editor-tab.h	Sun Aug 13 00:33:25 2017 +0200
@@ -136,7 +136,7 @@
 
   void new_file (const QString& commands = QString ());
 
-  void file_has_changed (const QString& do_close);
+  void file_has_changed (const QString& path, bool do_close = false);
 
   void handle_context_menu_edit (const QString&);
   void handle_context_menu_break_condition (int linenr);
--- a/libgui/src/m-editor/file-editor.cc	Sat Aug 12 14:02:29 2017 -0700
+++ b/libgui/src/m-editor/file-editor.cc	Sun Aug 13 00:33:25 2017 +0200
@@ -602,7 +602,7 @@
       if (editor_tab)
         {
           _external_close_request = true;  // Remember for not focussing editor
-          editor_tab->file_has_changed ("close");  // Close the tab
+          editor_tab->file_has_changed (QString (), true);  // Close the tab
           _external_close_request = false;  // Back to normal
         }
     }