# HG changeset patch # User Jacob Dawid # Date 1340302710 -7200 # Node ID 85daba52b2d4966ea6547bb9c93050b0c1b947b0 # Parent 7e41fcbb23a4cdf10a873d13e5dc86fca8280b73 Fixed bug with editor complaining that a file has been modified by another application when saving. * file-editor-tab.cc: Now "unwatching" file before saving. * file-editor-tab: Renamed slot to update window title. * file-editor.cc: Renamed slot to update window title. diff -r 7e41fcbb23a4 -r 85daba52b2d4 gui/src/m-editor/file-editor-tab.cc --- a/gui/src/m-editor/file-editor-tab.cc Thu Jun 21 16:18:39 2012 +0200 +++ b/gui/src/m-editor/file-editor-tab.cc Thu Jun 21 20:18:30 2012 +0200 @@ -79,14 +79,14 @@ // connect modified signal connect (_edit_area, SIGNAL (modificationChanged (bool)), - this, SLOT (new_title (bool))); + this, SLOT (update_window_title (bool))); connect (_edit_area, SIGNAL (copyAvailable (bool)), this, SLOT (handle_copy_available (bool))); connect (&_file_system_watcher, SIGNAL (fileChanged (QString)), this, SLOT (file_has_changed (QString))); _file_name = ""; - new_title (false); + update_window_title (false); } bool @@ -180,7 +180,7 @@ } void -file_editor_tab::new_title(bool modified) +file_editor_tab::update_window_title(bool modified) { QString title(_file_name); if ( !_long_title ) @@ -371,7 +371,7 @@ update_tracked_file (); - new_title (false); // window title (no modification) + update_window_title (false); // window title (no modification) _edit_area->setModified (false); // loaded file is not modified yet } @@ -384,7 +384,7 @@ } set_file_name (UNNAMED_FILE); - new_title (false); // window title (no modification) + update_window_title (false); // window title (no modification) _edit_area->setText (""); _edit_area->setModified (false); // new file is not modified yet } @@ -403,6 +403,9 @@ return save_file_as(); } + QStringList watched_files = _file_system_watcher.files(); + _file_system_watcher.removePaths(watched_files); + // open the file for writing QFile file (saveFileName); if (!file.open (QFile::WriteOnly)) @@ -410,6 +413,7 @@ QMessageBox::warning (this, tr ("Octave Editor"), tr ("Could not open file %1 for write:\n%2."). arg (saveFileName).arg (file.errorString ())); + _file_system_watcher.addPaths (watched_files); return false; } @@ -418,9 +422,12 @@ QApplication::setOverrideCursor (Qt::WaitCursor); out << _edit_area->text (); QApplication::restoreOverrideCursor (); - set_file_name (saveFileName); // save file name for later use - new_title (false); // set the window title to actual file name (not modified) + _file_name = saveFileName; // save file name for later use + update_window_title (false); // set the window title to actual file name (not modified) _edit_area->setModified (false); // files is save -> not modified + file.close(); + + _file_system_watcher.addPaths (watched_files); return true; } @@ -501,7 +508,7 @@ if (!save_file_as ()) { set_file_name (UNNAMED_FILE); - new_title (true); // window title (no modification) + update_window_title (true); // window title (no modification) set_modified (true); update_tracked_file (); } diff -r 7e41fcbb23a4 -r 85daba52b2d4 gui/src/m-editor/file-editor-tab.h --- a/gui/src/m-editor/file-editor-tab.h Thu Jun 21 16:18:39 2012 +0200 +++ b/gui/src/m-editor/file-editor-tab.h Thu Jun 21 20:18:30 2012 +0200 @@ -32,7 +32,7 @@ bool copy_available (); public slots: - void new_title(bool modified); + void update_window_title(bool modified); void handle_copy_available(bool enableCopy); void handle_margin_clicked (int line, int margin, Qt::KeyboardModifiers state); void comment_selected_text (); diff -r 7e41fcbb23a4 -r 85daba52b2d4 gui/src/m-editor/file-editor.cc --- a/gui/src/m-editor/file-editor.cc Thu Jun 21 16:18:39 2012 +0200 +++ b/gui/src/m-editor/file-editor.cc Thu Jun 21 20:18:30 2012 +0200 @@ -353,7 +353,7 @@ _cut_action->setShortcutContext (Qt::WindowShortcut); paste_action->setShortcut (QKeySequence::Paste); paste_action->setShortcutContext (Qt::WindowShortcut); - run_action->setShortcut (Qt::Key_F5); + run_action->setShortcut (Qt::SHIFT + Qt::Key_F5); run_action->setShortcutContext (Qt::WindowShortcut); next_bookmark_action->setShortcut (Qt::Key_F2); next_bookmark_action->setShortcutContext (Qt::WindowShortcut);