forked from qt-creator/qt-creator
Debugger: Fix "{En,Dis}able All Breakpoints" context menu action
The actual set of breakpoints to which the option was applied could have been different than the one used at the time of the creation of the context menu due to background activity. Found by crash reporter. Change-Id: I43a75c8659fe8a11988fa081022965db4ce9233c Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -1668,35 +1668,31 @@ bool BreakHandler::contextMenuEvent(const ItemViewEvent &ev)
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
QList<Breakpoint> enabledBreakpoints;
|
bool canDisableAll = false;
|
||||||
QList<Breakpoint> disabledBreakpoints;
|
bool canEnableAll = false;
|
||||||
forItemsAtLevel<1>([&enabledBreakpoints, &disabledBreakpoints](Breakpoint bp) {
|
forItemsAtLevel<1>([&canDisableAll, &canEnableAll](Breakpoint bp) {
|
||||||
if (bp) {
|
if (bp)
|
||||||
if (bp->isEnabled())
|
(bp->isEnabled() ? canDisableAll : canEnableAll) = true;
|
||||||
enabledBreakpoints.append(bp);
|
|
||||||
else
|
|
||||||
disabledBreakpoints.append(bp);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
addAction(this, menu, Tr::tr("Disable All Breakpoints"),
|
addAction(this, menu, Tr::tr("Disable All Breakpoints"), canDisableAll, [this] {
|
||||||
!enabledBreakpoints.isEmpty(),
|
forItemsAtLevel<1>([this](Breakpoint bp) {
|
||||||
[this, enabledBreakpoints] {
|
if (bp && bp->isEnabled()) {
|
||||||
for (Breakpoint bp : enabledBreakpoints) {
|
if (GlobalBreakpoint gbp = bp->globalBreakpoint())
|
||||||
if (GlobalBreakpoint gbp = bp->globalBreakpoint())
|
gbp->setEnabled(false, false);
|
||||||
gbp->setEnabled(false, false);
|
requestBreakpointEnabling(bp, false);
|
||||||
requestBreakpointEnabling(bp, false);
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
addAction(this, menu, Tr::tr("Enable All Breakpoints"),
|
addAction(this, menu, Tr::tr("Enable All Breakpoints"), canEnableAll, [this] {
|
||||||
!disabledBreakpoints.isEmpty(),
|
forItemsAtLevel<1>([this](Breakpoint bp) {
|
||||||
[this, disabledBreakpoints] {
|
if (bp && !bp->isEnabled()) {
|
||||||
for (Breakpoint bp : disabledBreakpoints) {
|
if (GlobalBreakpoint gbp = bp->globalBreakpoint())
|
||||||
if (GlobalBreakpoint gbp = bp->globalBreakpoint())
|
gbp->setEnabled(true, false);
|
||||||
gbp->setEnabled(true, false);
|
requestBreakpointEnabling(bp, true);
|
||||||
requestBreakpointEnabling(bp, true);
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
addAction(this, menu,
|
addAction(this, menu,
|
||||||
|
Reference in New Issue
Block a user