diff --git a/spyder/plugins/editor.py b/spyder/plugins/editor.py index 743b4c04d63..350f261dee1 100644 --- a/spyder/plugins/editor.py +++ b/spyder/plugins/editor.py @@ -1238,7 +1238,7 @@ def register_editorstack(self, editorstack): self.set_last_focus_editorstack(self, editorstack) editorstack.set_closable( len(self.editorstacks) > 1 ) if self.outlineexplorer is not None: - editorstack.set_outlineexplorer(self.outlineexplorer) + editorstack.set_outlineexplorer(self.outlineexplorer.explorer) editorstack.set_find_widget(self.find_widget) editorstack.reset_statusbar.connect(self.readwrite_status.hide) editorstack.reset_statusbar.connect(self.encoding_status.hide) @@ -1472,13 +1472,15 @@ def get_filename_index(self, filename): def get_current_editorstack(self, editorwindow=None): if self.editorstacks is not None: if len(self.editorstacks) == 1: - return self.editorstacks[0] + editorstack = self.editorstacks[0] else: editorstack = self.__get_focus_editorstack() if editorstack is None or editorwindow is not None: - return self.get_last_focus_editorstack(editorwindow) - return editorstack - + editorstack = self.get_last_focus_editorstack(editorwindow) + if editorstack is None: + editorstack = self.editorstacks[0] + return editorstack + def get_current_editor(self): editorstack = self.get_current_editorstack() if editorstack is not None: diff --git a/spyder/widgets/editor.py b/spyder/widgets/editor.py index b825c50115c..ec646d0353d 100644 --- a/spyder/widgets/editor.py +++ b/spyder/widgets/editor.py @@ -775,6 +775,12 @@ def add_corner_widgets_to_tabbar(self, widgets): def closeEvent(self, event): self.threadmanager.close_all_threads() self.analysis_timer.timeout.disconnect(self.analyze_script) + + # Remove editor references from the outline explorer settings + if self.outlineexplorer is not None: + for finfo in self.data: + self.outlineexplorer.remove_editor(finfo.editor) + QWidget.closeEvent(self, event) if is_pyqt46: self.destroyed.emit() @@ -2040,10 +2046,6 @@ def create_new_editor(self, fname, enc, txt, set_current, new=False, editor.zoom_out.connect(lambda: self.zoom_out.emit()) editor.zoom_reset.connect(lambda: self.zoom_reset.emit()) editor.sig_eol_chars_changed.connect(lambda eol_chars: self.refresh_eol_chars(eol_chars)) - if self.outlineexplorer is not None: - # Removing editor reference from outline explorer settings: - editor.destroyed.connect(lambda obj=editor: - self.outlineexplorer.remove_editor(obj)) self.find_widget.set_editor(editor) diff --git a/spyder/widgets/editortools.py b/spyder/widgets/editortools.py index a72df87f0ab..2168d5d593e 100644 --- a/spyder/widgets/editortools.py +++ b/spyder/widgets/editortools.py @@ -477,7 +477,6 @@ def activated(self, item): parent = self.current_editor.parent() for editor_id, i_item in list(self.editor_items.items()): if i_item is root_item: - #XXX: not working anymore!!! for editor, _id in list(self.editor_ids.items()): if _id == editor_id and editor.parent() is parent: self.current_editor = editor