Mercurial > octave
changeset 27653:3564d3999960
fix message box when trying to open a non-existant function in the editor
* main-window.cc (handle_edit_mfile_request): move message box from the
interpreter thread into a gui slot and just emit the related new signal;
(warning_function_not_found): new slot showing the message box
(construct): connect new signal to new slot
* main-window.h: new signal warning_function_not_found_signal and
new slot warning_function_not_found
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Thu, 07 Nov 2019 20:11:08 +0100 |
parents | f18e48749a7a |
children | 5e0f6db9428f |
files | libgui/src/main-window.cc libgui/src/main-window.h |
diffstat | 2 files changed, 23 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Thu Nov 07 10:03:28 2019 +0100 +++ b/libgui/src/main-window.cc Thu Nov 07 20:11:08 2019 +0100 @@ -1387,15 +1387,7 @@ if (! message.isEmpty ()) { - QMessageBox *msgBox - = new QMessageBox (QMessageBox::Critical, - tr ("Octave Editor"), - message.arg (fname), - QMessageBox::Ok, this); - - msgBox->setWindowModality (Qt::NonModal); - msgBox->setAttribute (Qt::WA_DeleteOnClose); - msgBox->show (); + emit warning_function_not_found_signal (message.arg (fname)); return; } @@ -1407,6 +1399,16 @@ }); } + void main_window::warning_function_not_found (const QString& message) + { + QMessageBox *msgBox = new QMessageBox (QMessageBox::Critical, + tr ("Octave Editor"), + message, QMessageBox::Ok, this); + msgBox->setWindowModality (Qt::NonModal); + msgBox->setAttribute (Qt::WA_DeleteOnClose); + msgBox->show (); + } + void main_window::handle_insert_debugger_pointer_request (const QString& file, int line) { @@ -2052,6 +2054,14 @@ connect (m_file_browser_window, SIGNAL (find_files_signal (const QString&)), this, SLOT (find_files (const QString&))); + // Connections for signals from the interpreter thread where the slot + // should be executed by the gui thread + + connect (this, SIGNAL (warning_function_not_found_signal (const QString&)), + this, SLOT (warning_function_not_found (const QString&))); + + // Build the window with widgets + setWindowTitle ("Octave"); // See Octave bug #53409 and https://bugreports.qt.io/browse/QTBUG-55357
--- a/libgui/src/main-window.h Thu Nov 07 10:03:28 2019 +0100 +++ b/libgui/src/main-window.h Thu Nov 07 20:11:08 2019 +0100 @@ -117,6 +117,8 @@ void add_actions_signal (QList <QAction *> action_list); + void warning_function_not_found_signal (const QString& message); + void interpreter_event (const fcn_callback& fcn); void interpreter_event (const meth_callback& meth); @@ -239,6 +241,8 @@ void set_file_encoding (const QString& new_encoding); void request_open_files (const QStringList& open_file_names); + void warning_function_not_found (const QString& message); + //! Opens the variable editor for @p name. void edit_variable (const QString &name, const octave_value&);