Skip to content

Commit

Permalink
[console] Correctly save settings when exiting app
Browse files Browse the repository at this point in the history
The closeEvent approach which was previously used is not reliable
on application exit, so manually force a settings save in this case too.

Avoids loss of command history when closing QGIS

Also remove the manual "Save" history action, as it's redundant
  • Loading branch information
nyalldawson committed Dec 5, 2018
1 parent 1f1bbba commit cce5c4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 4 additions & 0 deletions python/console/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def __init__(self, parent=None):
if iface and not iface.mainWindow().restoreDockWidget(self):
iface.mainWindow().addDockWidget(Qt.BottomDockWidgetArea, self)

# closeEvent is not always called for this widget -- so we also trigger a settings
# save on application exit
QgsApplication.instance().aboutToQuit.connect(self.console.saveSettingsConsole)

def activate(self):
self.activateWindow()
self.raise_()
Expand Down
5 changes: 0 additions & 5 deletions python/console/console_sci.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,6 @@ def contextMenuEvent(self, e):
subMenu.addAction(
QCoreApplication.translate("PythonConsole", "Show"),
self.showHistory, 'Ctrl+Shift+SPACE')
subMenu.addSeparator()
subMenu.addAction(
QCoreApplication.translate("PythonConsole", "Save"),
self.writeHistoryFile)
subMenu.addSeparator()
subMenu.addAction(
QCoreApplication.translate("PythonConsole", "Clear File"),
self.clearHistory)
Expand Down

0 comments on commit cce5c4e

Please sign in to comment.