Skip to content

Commit

Permalink
Merge pull request #6173 from ccordoba12/fix-last-plugin
Browse files Browse the repository at this point in the history
PR: Fix error when trying to maximize plugins that don't have a dock widget
  • Loading branch information
ccordoba12 authored Jan 8, 2018
2 parents 8636cb0 + fc0ae66 commit e40193b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion spyder/app/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2257,16 +2257,29 @@ def maximize_dockwidget(self, restore=False):
if self.state_before_maximizing is None:
if restore:
return
# No plugin is currently maximized: maximizing focus plugin

# Select plugin to maximize
self.state_before_maximizing = self.saveState()
focus_widget = QApplication.focusWidget()
for plugin in self.widgetlist:
plugin.dockwidget.hide()
if plugin.isAncestorOf(focus_widget):
self.last_plugin = plugin

# Only plugins that have a dockwidget are part of widgetlist,
# so last_plugin can be None after the above "for" cycle.
# For example, this happens if, after Spyder has started, focus
# is set to the Working directory toolbar (which doesn't have
# a dockwidget) and then you press the Maximize button
if self.last_plugin is None:
# Using the Editor as default plugin to maximize
self.last_plugin = self.editor

# Maximize last_plugin
self.last_plugin.dockwidget.toggleViewAction().setDisabled(True)
self.setCentralWidget(self.last_plugin)
self.last_plugin.ismaximized = True

# Workaround to solve an issue with editor's outline explorer:
# (otherwise the whole plugin is hidden and so is the outline explorer
# and the latter won't be refreshed if not visible)
Expand Down

0 comments on commit e40193b

Please sign in to comment.