--- a/eric7/Debugger/BreakPointViewer.py Fri Aug 20 14:19:55 2021 +0200 +++ b/eric7/Debugger/BreakPointViewer.py Fri Aug 20 18:02:46 2021 +0200 @@ -59,12 +59,6 @@ self.__createPopupMenus() - self.condHistory = [] - self.fnHistory = [] - self.fnHistory.append('') - - self.__loadRecent() - def setModel(self, model): """ Public slot to set the breakpoint model. @@ -173,6 +167,9 @@ self.menu.addSeparator() self.menu.addAction(self.tr("Goto"), self.__showSource) self.menu.addSeparator() + self.menu.addAction(self.tr("Clear Histories"), + self.clearHistories) + self.menu.addSeparator() self.menu.addAction(self.tr("Configure..."), self.__configure) self.backMenuActions = {} @@ -187,9 +184,12 @@ self.backMenuActions["DeleteAll"] = self.backMenu.addAction( self.tr("Delete all"), self.__deleteAllBreaks) - self.backMenu.aboutToShow.connect(self.__showBackMenu) + self.backMenu.addSeparator() + self.backMenu.addAction(self.tr("Clear Histories"), + self.clearHistories) self.backMenu.addSeparator() self.backMenu.addAction(self.tr("Configure..."), self.__configure) + self.backMenu.aboutToShow.connect(self.__showBackMenu) self.multiMenu = QMenu() self.multiMenu.addAction(self.tr("Add"), self.__addBreak) @@ -209,6 +209,9 @@ self.multiMenu.addAction(self.tr("Delete all"), self.__deleteAllBreaks) self.multiMenu.addSeparator() + self.multiMenu.addAction(self.tr("Clear Histories"), + self.clearHistories) + self.multiMenu.addSeparator() self.multiMenu.addAction(self.tr("Configure..."), self.__configure) def __showContextMenu(self, coord): @@ -245,22 +248,24 @@ """ from .EditBreakpointDialog import EditBreakpointDialog - dlg = EditBreakpointDialog((self.fnHistory[0], None), None, - self.condHistory, self, modal=1, - addMode=1, filenameHistory=self.fnHistory) + fnHistory, condHistory = self.__loadRecent() + + dlg = EditBreakpointDialog((fnHistory[0], None), None, + condHistory, self, modal=1, + addMode=1, filenameHistory=fnHistory) if dlg.exec() == QDialog.DialogCode.Accepted: fn, line, cond, temp, enabled, count = dlg.getAddData() if fn is not None: - if fn in self.fnHistory: - self.fnHistory.remove(fn) - self.fnHistory.insert(0, fn) + if fn in fnHistory: + fnHistory.remove(fn) + fnHistory.insert(0, fn) if cond: - if cond in self.condHistory: - self.condHistory.remove(cond) - self.condHistory.insert(0, cond) + if cond in condHistory: + condHistory.remove(cond) + condHistory.insert(0, cond) - self.__saveRecent() + self.__saveRecent(fnHistory, condHistory) self.__model.addBreakPoint(fn, line, (cond, temp, enabled, count)) self.__resizeColumns() @@ -304,19 +309,20 @@ return fn, line, cond, temp, enabled, count = bp[:6] + fnHistory, condHistory = self.__loadRecent() from .EditBreakpointDialog import EditBreakpointDialog dlg = EditBreakpointDialog( (fn, line), (cond, temp, enabled, count), - self.condHistory, self, modal=True) + condHistory, self, modal=True) if dlg.exec() == QDialog.DialogCode.Accepted: cond, temp, enabled, count = dlg.getData() if cond: - if cond in self.condHistory: - self.condHistory.remove(cond) - self.condHistory.insert(0, cond) + if cond in condHistory: + condHistory.remove(cond) + condHistory.insert(0, cond) - self.__saveRecent() + self.__saveRecent(fnHistory, condHistory) self.__model.setBreakPointByIndex( sindex, fn, line, (cond, temp, enabled, count)) @@ -495,34 +501,54 @@ def __loadRecent(self): """ - Private method to load the recently used file names. + Private method to load the recently used file names and breakpoint + conditions. + + @return tuple containing the recently used file names and breakpoint + conditions + @rtype tuple of (list of str, list of str) """ Preferences.Prefs.rsettings.sync() # load recently used file names - self.fnHistory = [] - self.fnHistory.append('') + fnHistory = [] + fnHistory.append('') rs = Preferences.Prefs.rsettings.value(recentNameBreakpointFiles) if rs is not None: recent = [f for f in Preferences.toList(rs) if QFileInfo(f).exists()] - self.fnHistory.extend( + fnHistory.extend( recent[:Preferences.getDebugger("RecentNumber")]) # load recently entered condition expressions - self.condHistory = [] + condHistory = [] rs = Preferences.Prefs.rsettings.value(recentNameBreakpointConditions) if rs is not None: - self.condHistory = Preferences.toList(rs)[ + condHistory = Preferences.toList(rs)[ :Preferences.getDebugger("RecentNumber")] + + return fnHistory, condHistory - def __saveRecent(self): + def __saveRecent(self, fnHistory, condHistory): """ - Private method to save the list of recently used file names. + Private method to save the list of recently used file names and + breakpoint conditions. + + @param fnHistory list of recently used file names + @type list of str + @param condHistory list of recently used breakpoint conditions + @type list of str """ - recent = [f for f in self.fnHistory if f] + recent = [f for f in fnHistory if f] Preferences.Prefs.rsettings.setValue(recentNameBreakpointFiles, recent) Preferences.Prefs.rsettings.setValue(recentNameBreakpointConditions, - self.condHistory) + condHistory) Preferences.Prefs.rsettings.sync() + + def clearHistories(self): + """ + Public method to clear the recently used file names and breakpoint + conditions. + """ + self.__saveRecent([], [])