Skip to content

Commit

Permalink
Merge pull request #5166 from jnsebgosselin/fix_split_outline_error
Browse files Browse the repository at this point in the history
PR: Fix RuntimeError and AttributeError when using outline and split code editor
  • Loading branch information
ccordoba12 authored Sep 8, 2017
2 parents c88de18 + f577c26 commit 315afa7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
10 changes: 6 additions & 4 deletions spyder/plugins/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1456,13 +1456,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:
Expand Down
10 changes: 6 additions & 4 deletions spyder/widgets/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,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()
Expand Down Expand Up @@ -2020,10 +2026,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)

Expand Down
1 change: 0 additions & 1 deletion spyder/widgets/editortools.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,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
Expand Down

0 comments on commit 315afa7

Please sign in to comment.