diff --git a/libgui/src/m-editor/file-editor-tab.cc b/libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -816,11 +816,24 @@ void file_editor_tab::update_lexer_setti if (m_is_octave_file) { + // Using a guarded pointer allows us to check whether this + // file_editor_tab is still valid when the + // interpreter_event callback function executes. + + QPointer this_tab (this); + emit interpreter_event ([=] (interpreter& interp) { // INTERPRETER THREAD + if (this_tab.isNull ()) + { + // Exit early if this tab was deleted before the + // callback could be executed. + return; + } + QStringList api_entries; octave_value_list tmp = Fiskeyword ();