Mercurial > hg > octave-lojdl
changeset 14689:dd19de736ee4 gui
Fixed crash on exit. Typing exit in the terminal works, too.
* OctaveLink.cpp: Added octave_exit hook and changed terminateOctave method.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Fri, 25 May 2012 20:54:36 +0200 |
parents | 9ea75ea686b5 |
children | ca733a66be7a |
files | gui/src/backend/OctaveLink.cpp |
diffstat | 1 files changed, 14 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/backend/OctaveLink.cpp +++ b/gui/src/backend/OctaveLink.cpp @@ -18,15 +18,21 @@ #include "OctaveLink.h" #include "load-path.h" #include <QDir> +#include <QApplication> -int update_hook_impl() +int octave_readline_hook () { - OctaveLink::instance()->triggerUpdateHistoryModel(); - OctaveLink::instance()->triggerCacheSymbolTable(); - QDir::setCurrent(load_path::get_command_line_path().c_str()); + OctaveLink::instance ()->triggerUpdateHistoryModel (); + OctaveLink::instance ()->triggerCacheSymbolTable (); + QDir::setCurrent (load_path::get_command_line_path ().c_str ()); return 0; } +void octave_exit_hook (int status) +{ + OctaveLink::instance ()->terminateOctave (); +} + OctaveLink OctaveLink::m_singleton; OctaveLink::OctaveLink ():QObject () @@ -54,7 +60,9 @@ { // Create both threads. m_octaveMainThread = new OctaveMainThread (this); - command_editor::add_event_hook(update_hook_impl); + command_editor::add_event_hook (octave_readline_hook); + octave_exit = octave_exit_hook; + // Start the first one. m_octaveMainThread->start (); _updateWorkspaceModelTimer.start (); @@ -63,9 +71,7 @@ void OctaveLink::terminateOctave () { - m_octaveMainThread->terminate (); - quit_allowed = true; - m_octaveMainThread->wait(); + QMetaObject::invokeMethod (qApp, "quit"); } void