Debugger: Fix crash when trying to remove all breakpoints of a file

Change-Id: Iea4478804be7b32a2da924e1163c5c4944c6e8a4
Fixes: QTCREATORBUG-24306
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2020-08-11 10:09:54 +02:00
parent 501e7c2fdd
commit 27c3550d44

View File

@@ -2629,15 +2629,16 @@ bool BreakpointManager::contextMenuEvent(const ItemViewEvent &ev)
rowCount() > 0, rowCount() > 0,
&BreakpointManager::executeDeleteAllBreakpointsDialog); &BreakpointManager::executeDeleteAllBreakpointsDialog);
// Delete by file: Find indices of breakpoints of the same file. // Delete by file: Find breakpoints of the same file.
GlobalBreakpoints breakpointsInFile; GlobalBreakpoints breakpointsInFile;
FilePath file; FilePath file;
if (GlobalBreakpoint gbp = itemForIndexAtLevel<1>(ev.sourceModelIndex())) { if (GlobalBreakpoint gbp = itemForIndexAtLevel<1>(ev.sourceModelIndex())) {
file = gbp->markerFileName(); file = gbp->markerFileName();
if (!file.isEmpty()) { if (!file.isEmpty()) {
for (int i = 0; i != rowCount(); ++i) forItemsAtLevel<1>([file, &breakpointsInFile](const GlobalBreakpoint &gbp) {
if (gbp->markerFileName() == file) if (gbp->markerFileName() == file)
breakpointsInFile.append(gbp); breakpointsInFile.append(gbp);
});
} }
} }
addAction(menu, tr("Delete Breakpoints of \"%1\"").arg(file.toUserOutput()), addAction(menu, tr("Delete Breakpoints of \"%1\"").arg(file.toUserOutput()),