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,36 +1668,32 @@ bool BreakHandler::contextMenuEvent(const ItemViewEvent &ev)
|
||||
}
|
||||
);
|
||||
|
||||
QList<Breakpoint> enabledBreakpoints;
|
||||
QList<Breakpoint> disabledBreakpoints;
|
||||
forItemsAtLevel<1>([&enabledBreakpoints, &disabledBreakpoints](Breakpoint bp) {
|
||||
if (bp) {
|
||||
if (bp->isEnabled())
|
||||
enabledBreakpoints.append(bp);
|
||||
else
|
||||
disabledBreakpoints.append(bp);
|
||||
}
|
||||
bool canDisableAll = false;
|
||||
bool canEnableAll = false;
|
||||
forItemsAtLevel<1>([&canDisableAll, &canEnableAll](Breakpoint bp) {
|
||||
if (bp)
|
||||
(bp->isEnabled() ? canDisableAll : canEnableAll) = true;
|
||||
});
|
||||
|
||||
addAction(this, menu, Tr::tr("Disable All Breakpoints"),
|
||||
!enabledBreakpoints.isEmpty(),
|
||||
[this, enabledBreakpoints] {
|
||||
for (Breakpoint bp : enabledBreakpoints) {
|
||||
addAction(this, menu, Tr::tr("Disable All Breakpoints"), canDisableAll, [this] {
|
||||
forItemsAtLevel<1>([this](Breakpoint bp) {
|
||||
if (bp && bp->isEnabled()) {
|
||||
if (GlobalBreakpoint gbp = bp->globalBreakpoint())
|
||||
gbp->setEnabled(false, false);
|
||||
requestBreakpointEnabling(bp, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
addAction(this, menu, Tr::tr("Enable All Breakpoints"),
|
||||
!disabledBreakpoints.isEmpty(),
|
||||
[this, disabledBreakpoints] {
|
||||
for (Breakpoint bp : disabledBreakpoints) {
|
||||
addAction(this, menu, Tr::tr("Enable All Breakpoints"), canEnableAll, [this] {
|
||||
forItemsAtLevel<1>([this](Breakpoint bp) {
|
||||
if (bp && !bp->isEnabled()) {
|
||||
if (GlobalBreakpoint gbp = bp->globalBreakpoint())
|
||||
gbp->setEnabled(true, false);
|
||||
requestBreakpointEnabling(bp, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
addAction(this, menu,
|
||||
selectedLocations.size() > 1
|
||||
|
Reference in New Issue
Block a user