Commit c60e8303 authored by Igor Kushnir's avatar Igor Kushnir

Check ICore::activeSession() for nullptr in BreakpointModel::save()

When a user exits KDevelop while debugging a program, a queued call to
BreakpointModel::save() may be invoked during Core::cleanup() or perhaps
even during ~CorePrivate(). If this happens between
SessionController::cleanup() and ~DebugController() (which is the parent
of BreakpointModel), the result is a crash. A breakpoint change that is
saved at this time is likely unimportant and can be safely skipped.

BUG: 425986
FIXED-IN: 5.6.1
parent 89ffddc7
...@@ -574,7 +574,14 @@ void BreakpointModel::save() ...@@ -574,7 +574,14 @@ void BreakpointModel::save()
d->dirty = false; d->dirty = false;
KConfigGroup breakpoints = ICore::self()->activeSession()->config()->group("Breakpoints"); auto* const activeSession = ICore::self()->activeSession();
if (!activeSession) {
qCDebug(DEBUGGER) << "Cannot save breakpoints because there is no active session. "
"KDevelop must be exiting and already past SessionController::cleanup().";
KConfigGroup breakpoints = activeSession->config()->group("Breakpoints");
breakpoints.writeEntry("number", d->breakpoints.count()); breakpoints.writeEntry("number", d->breakpoints.count());
int i = 0; int i = 0;
for (Breakpoint* b : qAsConst(d->breakpoints)) { for (Breakpoint* b : qAsConst(d->breakpoints)) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment