Mercurial > octave
changeset 24082:0052d47ddc3e
Backed out changeset ba164db1c4a4
author | Torsten <mttl@mailbox.org> |
---|---|
date | Fri, 22 Sep 2017 03:04:23 +0200 |
parents | ae8e3e81f372 |
children | 1457c018b683 |
files | libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h libgui/src/main-window.cc libgui/src/octave-qt-link.cc libgui/src/octave-qt-link.h libinterp/corefcn/dirfns.cc libinterp/corefcn/octave-link.cc libinterp/corefcn/octave-link.h libinterp/corefcn/syscalls.cc |
diffstat | 9 files changed, 35 insertions(+), 125 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc Tue Sep 12 19:53:22 2017 -0500 +++ b/libgui/src/m-editor/file-editor.cc Fri Sep 22 03:04:23 2017 +0200 @@ -1054,56 +1054,49 @@ // is going to be deleted/renamed void file_editor::handle_file_remove (const QString& old_name, - const QString& new_name, - QMutex *wait_closing) + const QString& new_name) { // Clear old lsit of files to reload m_tmp_closed_files.clear (); // Check if old name is a file or directory QFileInfo old (old_name); - if (old.isDir ()) { // Call the function which handles directories and return handle_dir_remove (old_name, new_name); + return; } - else + + // Is old file open? + file_editor_tab *editor_tab + = static_cast<file_editor_tab *> (find_tab_widget (old_name)); + + if (editor_tab) { - // It is a single file. IT is open? - file_editor_tab *editor_tab - = static_cast<file_editor_tab *> (find_tab_widget (old_name)); - - if (editor_tab) + // Yes, close it silently + m_no_focus = true; // Remember for not focussing editor + editor_tab->file_has_changed (QString (), true); // Close the tab + m_no_focus = false; // Back to normal + + m_tmp_closed_files << old_name; // for reloading if error removing + + if (! new_name.isEmpty ()) + m_tmp_closed_files << new_name; // store new name + else + m_tmp_closed_files << ""; // no new name, just removing this file + + // Get and store the related encoding + for (editor_tab_map_const_iterator p = m_editor_tab_map.begin (); + p != m_editor_tab_map.end (); p++) { - // Yes, close it silently - m_no_focus = true; // Remember for not focussing editor - editor_tab->file_has_changed (QString (), true); // Close the tab - m_no_focus = false; // Back to normal - - m_tmp_closed_files << old_name; // for reloading if error removing - - if (! new_name.isEmpty ()) - m_tmp_closed_files << new_name; // store new name - else - m_tmp_closed_files << ""; // no new name, just removing this file - - // Get and store the related encoding - for (editor_tab_map_const_iterator p = m_editor_tab_map.begin (); - p != m_editor_tab_map.end (); p++) + if (editor_tab == p->second.fet_ID) { - if (editor_tab == p->second.fet_ID) - { - m_tmp_closed_files << p->second.encoding; - break; - } + m_tmp_closed_files << p->second.encoding; + break; } } } - - // Finally, if a mutex was given, unlock it for enabling the removing - if (wait_closing) - wait_closing->unlock (); } // Slot for signal indicating that a file was renamed
--- a/libgui/src/m-editor/file-editor.h Tue Sep 12 19:53:22 2017 -0500 +++ b/libgui/src/m-editor/file-editor.h Fri Sep 22 03:04:23 2017 +0200 @@ -26,7 +26,6 @@ #include <QToolBar> #include <QAction> #include <QMenuBar> -#include <QMutex> #include <QStatusBar> #include <QCloseEvent> #include <QTabWidget> @@ -282,8 +281,7 @@ void handle_edit_file_request (const QString& file); - void handle_file_remove (const QString&, const QString&, - QMutex *wait_closing = 0); + void handle_file_remove (const QString&, const QString&); void handle_file_renamed (bool load_new = true); // Tells the editor to react on changed settings.
--- a/libgui/src/main-window.cc Tue Sep 12 19:53:22 2017 -0500 +++ b/libgui/src/main-window.cc Fri Sep 22 03:04:23 2017 +0200 @@ -1946,7 +1946,6 @@ int, const QString&))); - // Signals for removing/renaming files/dirs in the file browser connect (m_file_browser_window, SIGNAL (file_remove_signal (const QString&, const QString&)), m_editor_window, @@ -1954,15 +1953,6 @@ connect (m_file_browser_window, SIGNAL (file_renamed_signal (bool)), m_editor_window, SLOT (handle_file_renamed (bool))); - // Signals for removing/renaming files/dirs in the temrinal window - connect (m_octave_qt_link, - SIGNAL (file_remove_signal (const QString&, const QString&, - QMutex*)), - m_editor_window, - SLOT (handle_file_remove (const QString&, const QString&, - QMutex*))); - connect (m_octave_qt_link, SIGNAL (file_renamed_signal (bool)), - m_editor_window, SLOT (handle_file_renamed (bool))); #endif octave_link::post_event (this,
--- a/libgui/src/octave-qt-link.cc Tue Sep 12 19:53:22 2017 -0500 +++ b/libgui/src/octave-qt-link.cc Fri Sep 22 03:04:23 2017 +0200 @@ -422,31 +422,6 @@ } void -octave_qt_link::do_file_remove (const std::string& old_name, - const std::string& new_name) -{ - QMutex wait_closing; - - // Emit the signal for the editor for closing the file if it is open - emit file_remove_signal (QString::fromStdString (old_name), - QString::fromStdString (new_name), &wait_closing); - - // Unlock and lock the mutex (make sure it is locked without being blocked) - wait_closing.unlock (); - wait_closing.lock (); - // Try to lock it again, thus waiting for the unlock of the editor after - // closing the files. Chose a timeout of 1 s for not being blocked forever - // when something goes wrong - wait_closing.tryLock (1000); -} - -void -octave_qt_link::do_file_renamed (bool load_new) -{ - emit file_renamed_signal (load_new); -} - -void octave_qt_link::do_execute_command_in_terminal (const std::string& command) { emit execute_command_in_terminal_signal (QString::fromStdString (command));
--- a/libgui/src/octave-qt-link.h Tue Sep 12 19:53:22 2017 -0500 +++ b/libgui/src/octave-qt-link.h Fri Sep 22 03:04:23 2017 +0200 @@ -110,10 +110,6 @@ void update_directory (void); - void do_file_remove (const std::string& old_name, - const std::string& new_name); - void do_file_renamed (bool load_new = true); - void do_execute_command_in_terminal (const std::string& command); void do_set_workspace (bool top_level, bool debug, @@ -177,10 +173,6 @@ void change_directory_signal (const QString& dir); - void file_remove_signal (const QString& old_name, - const QString& new_name, QMutex *wait_closing); - void file_renamed_signal (bool load_new); - void execute_command_in_terminal_signal (const QString& command); void set_workspace_signal (bool top_level,
--- a/libinterp/corefcn/dirfns.cc Tue Sep 12 19:53:22 2017 -0500 +++ b/libinterp/corefcn/dirfns.cc Fri Sep 22 03:04:23 2017 +0200 @@ -295,18 +295,10 @@ } if (doit) - { - octave_link::file_remove (fulldir, ""); - status = octave::sys::recursive_rmdir (fulldir, msg); - } + status = octave::sys::recursive_rmdir (fulldir, msg); } else - { - octave_link::file_remove (fulldir, ""); - status = octave::sys::rmdir (fulldir, msg); - } - - octave_link::file_renamed (status >= 0); + status = octave::sys::rmdir (fulldir, msg); if (status < 0) return ovl (false, msg, "rmdir"); @@ -429,20 +421,12 @@ std::string msg; - octave_link::file_remove (from, to); - int status = octave::sys::rename (from, to, msg); if (status < 0) - { - octave_link::file_renamed (false); - return ovl (-1.0, msg); - } + return ovl (-1.0, msg); else - { - octave_link::file_renamed (true); - return ovl (status, ""); - } + return ovl (status, ""); } DEFUN (glob, args, ,
--- a/libinterp/corefcn/octave-link.cc Tue Sep 12 19:53:22 2017 -0500 +++ b/libinterp/corefcn/octave-link.cc Fri Sep 22 03:04:23 2017 +0200 @@ -394,12 +394,12 @@ print_usage (); if (! args(0).is_string ()) - error ("openvar: NAME must be a string"); + error ("openvar: NAME must be a string"); std::string name = args(0).string_value (); if (! (Fisguirunning ())(0).is_true ()) - warning ("openvar: GUI is not running, can't start Variable Editor"); + warning ("openvar: GUI is not running, can't start Variable Editor"); else octave_link::openvar (name);
--- a/libinterp/corefcn/octave-link.h Tue Sep 12 19:53:22 2017 -0500 +++ b/libinterp/corefcn/octave-link.h Fri Sep 22 03:04:23 2017 +0200 @@ -31,7 +31,7 @@ #include <string> #include "oct-mutex.h" -#include "octave.h" + #include "event-queue.h" class string_vector; @@ -250,20 +250,6 @@ instance->do_change_directory (dir); } - // Methods for removing/renaming files which might be open in editor - static void file_remove (const std::string& old_name, - const std::string& new_name) - { - if (octave::application::is_gui_running () && enabled ()) - instance->do_file_remove (old_name, new_name); - } - - static void file_renamed (bool load_new) - { - if (octave::application::is_gui_running () && enabled ()) - instance->do_file_renamed (load_new); - } - // Preserves pending input. static void execute_command_in_terminal (const std::string& command) { @@ -552,10 +538,6 @@ virtual void do_change_directory (const std::string& dir) = 0; - virtual void do_file_remove (const std::string& old_name, - const std::string& new_name) = 0; - virtual void do_file_renamed (bool) = 0; - virtual void do_execute_command_in_terminal (const std::string& command) = 0; virtual void
--- a/libinterp/corefcn/syscalls.cc Tue Sep 12 19:53:22 2017 -0500 +++ b/libinterp/corefcn/syscalls.cc Fri Sep 22 03:04:23 2017 +0200 @@ -42,6 +42,7 @@ #include "oct-env.h" #include "oct-syscalls.h" #include "oct-uname.h" + #include "defun.h" #include "error.h" #include "errwarn.h" @@ -51,7 +52,6 @@ #include "ovl.h" #include "oct-stdstrm.h" #include "oct-stream.h" -#include "octave-link.h" #include "sysdep.h" #include "utils.h" #include "variables.h" @@ -1088,12 +1088,8 @@ std::string msg; - octave_link::file_remove (name, ""); - int status = octave::sys::unlink (name, msg); - octave_link::file_renamed (status == 0); - return ovl (status, msg); }