Debugger/BreakHandler: Add some guards when removing breakpoints

We've got a crash report when accessing the engine in that area, so the
question is if an engine can get deleted while the loop is running. Add
an explicit check. Also check for the precondition that each
BreakpointItem only belongs to a single engine.

Change-Id: I97b35aa6dedeb6b3cae956f549ea5fb77c61a00d
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2024-12-17 10:05:15 +01:00
parent 04fc1fcbce
commit c061dfad96
2 changed files with 11 additions and 4 deletions

View File

@@ -1521,8 +1521,15 @@ void BreakpointItem::deleteBreakpoint()
{
QTC_ASSERT(!globalBreakpoint(), return); // Use deleteBreakpoint(GlobalBreakpoint gbp) instead.
for (QPointer<DebuggerEngine> engine : EngineManager::engines())
engine->breakHandler()->requestBreakpointRemoval(this);
bool found = false;
for (QPointer<DebuggerEngine> engine : EngineManager::engines()) {
if (QTC_GUARD(engine)) {
QTC_CHECK(!found);
found = true;
engine->breakHandler()->requestBreakpointRemoval(this);
}
}
QTC_CHECK(found);
}
void BreakpointItem::deleteGlobalOrThisBreakpoint()

View File

@@ -616,8 +616,8 @@ QList<QPointer<DebuggerEngine>> EngineManager::engines()
{
QList<QPointer<DebuggerEngine>> result;
d->m_engineModel.forItemsAtLevel<1>([&result](EngineItem *engineItem) {
if (DebuggerEngine *engine = engineItem->m_engine)
result.append(engine);
if (engineItem->m_engine)
result.append(engineItem->m_engine);
});
return result;
}