diff --git a/libgui/src/main-window.cc b/libgui/src/main-window.cc --- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -91,9 +91,6 @@ // deleted before this main_window is. Otherwise, some will be // attached to a non-existent parent. - if (_octave_qt_event_listener) - delete _octave_qt_event_listener; - octave_link::connect_link (0); delete _octave_qt_link; } @@ -266,6 +263,12 @@ } void +main_window::exit (void) +{ + qApp->quit (); +} + +void main_window::reset_windows () { // TODO: Implement. @@ -542,8 +545,8 @@ construct_tool_bar (); - connect (qApp, SIGNAL (aboutToQuit ()), - this, SLOT (prepare_to_exit ())); + connect (qApp, SIGNAL (aboutToQuit ()), + this, SLOT (prepare_to_exit ())); connect (this, SIGNAL (settings_changed (const QSettings *)), this, SLOT (notice_settings (const QSettings *))); @@ -580,10 +583,6 @@ setStatusBar (status_bar); - _octave_qt_event_listener = new octave_qt_event_listener (); - - // FIXME -- is it possible to eliminate the event_listenter? - construct_octave_qt_link (); QDir curr_dir; @@ -595,6 +594,9 @@ { _octave_qt_link = new octave_qt_link (); + connect (_octave_qt_link, SIGNAL (octave_thread_finished ()), + this, SLOT (exit ())); + connect (_octave_qt_link, SIGNAL (set_workspace_signal (const QString&, const QStringList&, const QStringList&, @@ -651,8 +653,6 @@ _octave_qt_link->execute_interpreter (); octave_link::connect_link (_octave_qt_link); - - octave_link::register_event_listener (_octave_qt_event_listener); } void diff --git a/libgui/src/main-window.h b/libgui/src/main-window.h --- a/libgui/src/main-window.h +++ b/libgui/src/main-window.h @@ -51,7 +51,6 @@ #include "files-dock-widget.h" #include "terminal-dock-widget.h" #include "documentation-dock-widget.h" -#include "octave-qt-event-listener.h" #include "octave-qt-link.h" /** @@ -93,6 +92,7 @@ void show_about_octave (void); void notice_settings (const QSettings *settings); void prepare_to_exit (void); + void exit (void); void reset_windows (void); void change_directory (const QString& dir); @@ -206,8 +206,6 @@ static const int current_directory_max_count = 16; QLineEdit *_current_directory_line_edit; - octave_qt_event_listener *_octave_qt_event_listener; - octave_qt_link *_octave_qt_link; // Flag for closing whole application. diff --git a/libgui/src/module.mk b/libgui/src/module.mk --- a/libgui/src/module.mk +++ b/libgui/src/module.mk @@ -72,7 +72,6 @@ src/moc-files-dock-widget.cc \ src/moc-history-dock-widget.cc \ src/moc-main-window.cc \ - src/moc-octave-qt-event-listener.cc \ src/moc-octave-qt-link.cc \ src/moc-settings-dialog.cc \ src/moc-terminal-dock-widget.cc \ @@ -107,7 +106,6 @@ src/main-window.h \ src/octave-gui.h \ src/octave-main-thread.h \ - src/octave-qt-event-listener.h \ src/octave-qt-link.h \ src/qtinfo/parser.h \ src/qtinfo/webinfo.h \ @@ -130,7 +128,6 @@ src/main-window.cc \ src/octave-gui.cc \ src/octave-main-thread.cc \ - src/octave-qt-event-listener.cc \ src/octave-qt-link.cc \ src/qtinfo/parser.cc \ src/qtinfo/webinfo.cc \ diff --git a/libgui/src/octave-qt-event-listener.cc b/libgui/src/octave-qt-event-listener.cc deleted file mode 100644 --- a/libgui/src/octave-qt-event-listener.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* - -Copyright (C) 2011-2012 Jacob Dawid - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, see -. - -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "octave-qt-event-listener.h" -#include - -octave_qt_event_listener::octave_qt_event_listener (QObject *p) - : QObject (p), octave_event_listener () -{ -} - -void -octave_qt_event_listener::current_directory_has_changed (const std::string& directory) -{ - emit current_directory_has_changed_signal - (QString::fromUtf8 (directory.data (), directory.size ())); -} - -void -octave_qt_event_listener::update_workspace (void) -{ - emit update_workspace_signal (); -} - -void -octave_qt_event_listener::about_to_exit () -{ - qApp->quit (); -} diff --git a/libgui/src/octave-qt-event-listener.h b/libgui/src/octave-qt-event-listener.h deleted file mode 100644 --- a/libgui/src/octave-qt-event-listener.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - -Copyright (C) 2011-2012 Jacob Dawid - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, see -. - -*/ - -#ifndef OCTAVEQTEVENTLISTENER_H -#define OCTAVEQTEVENTLISTENER_H - -#include -#include -#include "octave-event-listener.h" - -class octave_qt_event_listener - : public QObject, public octave_event_listener -{ - Q_OBJECT - public: - octave_qt_event_listener (QObject *parent = 0); - - void current_directory_has_changed (const std::string& directory); - void update_workspace (void); - void about_to_exit (); - -signals: - void current_directory_has_changed_signal (const QString& directory); - void update_workspace_signal (void); -}; - -#endif // OCTAVEQTEVENTLISTENER_H diff --git a/libgui/src/octave-qt-link.cc b/libgui/src/octave-qt-link.cc --- a/libgui/src/octave-qt-link.cc +++ b/libgui/src/octave-qt-link.cc @@ -37,6 +37,8 @@ octave_qt_link::octave_qt_link (void) : octave_link (), main_thread (new octave_main_thread) { + connect (main_thread, SIGNAL (finished ()), + this, SIGNAL (octave_thread_finished ())); } void diff --git a/libgui/src/octave-qt-link.h b/libgui/src/octave-qt-link.h --- a/libgui/src/octave-qt-link.h +++ b/libgui/src/octave-qt-link.h @@ -115,6 +115,8 @@ void insert_debugger_pointer_signal (const QString&, int); void delete_debugger_pointer_signal (const QString&, int); + + void octave_thread_finished (void); }; #endif diff --git a/libinterp/interp-core/module.mk b/libinterp/interp-core/module.mk --- a/libinterp/interp-core/module.mk +++ b/libinterp/interp-core/module.mk @@ -35,7 +35,6 @@ interp-core/mex.h \ interp-core/mexproto.h \ interp-core/mxarray.in.h \ - interp-core/octave-event-listener.h \ interp-core/oct-errno.h \ interp-core/oct-fstrm.h \ interp-core/oct-hdf5.h \ diff --git a/libinterp/interp-core/octave-event-listener.h b/libinterp/interp-core/octave-event-listener.h deleted file mode 100644 --- a/libinterp/interp-core/octave-event-listener.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - -Copyright (C) 2011-2012 Jacob Dawid - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, see -. - -*/ - -#ifndef OCTAVEEVENTLISTENER_H -#define OCTAVEEVENTLISTENER_H - -#include - -class octave_event_listener -{ - public: - octave_event_listener () { } - virtual ~octave_event_listener () { } - - virtual void - update_workspace (void) = 0; - - virtual void about_to_exit () = 0; -}; - -#endif // OCTAVEEVENTLISTENER_H diff --git a/libinterp/interpfcn/octave-link.cc b/libinterp/interpfcn/octave-link.cc --- a/libinterp/interpfcn/octave-link.cc +++ b/libinterp/interpfcn/octave-link.cc @@ -46,21 +46,13 @@ return 0; } -static void -octave_exit_hook (int) -{ - octave_link::about_to_exit (); -} - octave_link *octave_link::instance = 0; octave_link::octave_link (void) - : event_listener (0), event_queue_mutex (new octave_mutex ()), + : event_queue_mutex (new octave_mutex ()), gui_event_queue (), debugging (false) { command_editor::add_event_hook (octave_readline_hook); - - octave_exit = octave_exit_hook; } // OBJ should be an object of a class that is derived from the base @@ -77,12 +69,6 @@ } void -octave_link::do_register_event_listener (octave_event_listener *el) -{ - event_listener = el; -} - -void octave_link::do_generate_events (void) { } @@ -97,19 +83,6 @@ event_queue_mutex->unlock (); } -void -octave_link::do_about_to_exit (void) -{ - event_queue_mutex->lock (); - - gui_event_queue.discard (); - - event_queue_mutex->unlock (); - - if (event_listener) - event_listener->about_to_exit (); -} - bool octave_link::instance_ok (void) { diff --git a/libinterp/interpfcn/octave-link.h b/libinterp/interpfcn/octave-link.h --- a/libinterp/interpfcn/octave-link.h +++ b/libinterp/interpfcn/octave-link.h @@ -28,7 +28,6 @@ #include #include "event-queue.h" -#include "octave-event-listener.h" class octave_mutex; class string_vector; @@ -52,12 +51,6 @@ virtual ~octave_link (void) { } - static void register_event_listener (octave_event_listener *el) - { - if (instance_ok ()) - instance->do_register_event_listener (el); - } - static void generate_events (void) { if (instance_ok ()) @@ -91,12 +84,6 @@ instance->do_post_event (obj, method, arg); } - static void about_to_exit (void) - { - if (instance_ok ()) - instance->do_about_to_exit (); - } - static void entered_readline_hook (void) { if (instance_ok ()) @@ -214,8 +201,6 @@ protected: - octave_event_listener *event_listener; - // Semaphore to lock access to the event queue. octave_mutex *event_queue_mutex; @@ -224,8 +209,6 @@ bool debugging; - void do_register_event_listener (octave_event_listener *oel); - void do_generate_events (void); void do_process_events (void); @@ -247,8 +230,6 @@ gui_event_queue.add_method (obj, method, arg); } - void do_about_to_exit (void); - void do_entered_readline_hook (void) { } void do_finished_readline_hook (void) { }