Skip to content

Commit 28146b5

Browse files
YoannQDQnyalldawson
authored andcommittedFeb 21, 2023
Fix Editor/EditorTab never deleted
1 parent 7f23109 commit 28146b5

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed
 

‎python/console/console_editor.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -698,10 +698,10 @@ def newTabEditor(self, tabName=None, filename=None):
698698
nr = self.count()
699699
if not tabName:
700700
tabName = QCoreApplication.translate('PythonConsole', 'Untitled-{0}').format(nr)
701-
self.tab = EditorTab(self, self.parent, filename, readOnly)
701+
tab = EditorTab(self, self.parent, filename, readOnly)
702702
self.iconTab = QgsApplication.getThemeIcon('console/iconTabEditorConsole.svg')
703-
self.addTab(self.tab, self.iconTab, tabName + ' (ro)' if readOnly else tabName)
704-
self.setCurrentWidget(self.tab)
703+
self.addTab(tab, self.iconTab, tabName + ' (ro)' if readOnly else tabName)
704+
self.setCurrentWidget(tab)
705705
if filename:
706706
self.setTabToolTip(self.currentIndex(), filename)
707707
else:
@@ -713,14 +713,6 @@ def tabModified(self, tab, modified):
713713
self.setTabTitle(index, '*{}'.format(s) if modified else re.sub(r'^(\*)', '', s))
714714
self.parent.saveFileButton.setEnabled(modified)
715715

716-
def closeTab(self, tab):
717-
if self.count() < 2:
718-
self.removeTab(self.indexOf(tab))
719-
self.newTabEditor()
720-
else:
721-
self.removeTab(self.indexOf(tab))
722-
self.currentWidget().setFocus(Qt.TabFocusReason)
723-
724716
def setTabTitle(self, tab, title):
725717
self.setTabText(tab, title)
726718

@@ -736,10 +728,10 @@ def _removeTab(self, tab, tab2index=False):
736728
res = QMessageBox.question(self, txtSaveOnRemove,
737729
txtMsgSaveOnRemove,
738730
QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
731+
if res == QMessageBox.Cancel:
732+
return
739733
if res == QMessageBox.Save:
740734
tabWidget.save()
741-
elif res == QMessageBox.Cancel:
742-
return
743735
if tabWidget.path:
744736
self.parent.updateTabListScript(tabWidget.path, action='remove')
745737
self.removeTab(tab)
@@ -753,6 +745,8 @@ def _removeTab(self, tab, tab2index=False):
753745
self.newTabEditor()
754746
else:
755747
self.removeTab(tab)
748+
749+
tabWidget.deleteLater()
756750
self.currentWidget().newEditor.setFocus(Qt.TabFocusReason)
757751

758752
def buttonClosePressed(self):

0 commit comments

Comments
 (0)
Please sign in to comment.