Public issue detail

Crash in yakuake: SEGV) si_code: SI_TKILL at KCrash::defaultCrashHandler(int) -> __restore_rt -> QWidget::focusWidget()…

Top frame: __pthread_kill_implementation [libc.so.6]

highpackage: yakuakesource: yakuakescore: 98reports: 1patch attempt ready

Last seen: 2026-07-10 02:44 UTC. Public JSON: /v1/issues/019f478f-3ab9-7aa2-af9f-76ffb768fd8b

Pull-request-ready diff

This is the current best public patch attempt for the issue. The downloadable `.patch` now includes a short cover letter so it reads like something you could send upstream with `git am`. If you only want the raw diff, grab the `.diff` instead.

best patchcreated: 2026-07-09 15:33 UTCvalidation: ready

Patch proposal created locally. Review it and submit it upstream if it looks correct.

Suggested subject

Focus raised sessions through their active terminal

Commit message.

When raising a session, focus the session’s tracked active terminal widget directly instead of asking Qt to rediscover the focused child through `QWidget::focusWidget()`. Yakuake already tracks the active terminal for each session, and using that stored terminal widget keeps the intended focus behavior while avoiding a fragile focus-chain lookup during session switching.

Problem. Top frame: __pthread_kill_implementation [libc.so.6].

How this patch connects to the issue.

Fixer observed a Yakuake SIGSEGV in a coredump from `/usr/bin/yakuake`; the stack entered `QWidget::focusWidget()` while Qt was processing focus events. I did not independently reproduce that crash.

The cautious code-level connection is that `SessionStack::raiseSession()` used `session->widget()->focusWidget()` immediately after changing the current stacked widget. The focus chain is Qt’s record of which child widget currently owns focus inside a parent widget. In this path Yakuake does not need Qt to rediscover that child: the `Session` already records its active `Terminal`, and `Terminal::terminalWidget()` is a guarded pointer to the embedded terminal widget.

The patch changes `raiseSession()` to fetch the active terminal via `session->getTerminal(session->activeTerminalId())` and focus that terminal widget if it still exists. This addresses the review finding by avoiding the `focusWidget()` call entirely in this path, rather than just reducing duplicate calls. The expected effect is to preserve session-raise focus behavior while avoiding the crash-adjacent Qt focus-chain lookup.

Files touched

  • app/sessionstack.cpp

Validation

  • Fixer marked this proposal `ready` on 2026-07-09 15:33 UTC.
  • The underlying issue cluster has 1 report(s) and was last seen 2026-07-10 02:44 UTC.
  • The published diff touches app/sessionstack.cpp.
  • Checked contribution/style context before editing: only `README.md` was present among the requested docs, and it describes standard KDE CMake build flow. The workspace branch is `master`. I found no relevant local helper wrapper for this GUI focus path; nearby code uses direct Qt/KF APIs and already uses `Session::getTerminal()`, `Session::activeTerminalId()`, and `Terminal::terminalWidget()` for focus restoration. Required project-level command attempted from workspace root: ```sh cmake -S . -B build-fix -G Ninja && cmake --build build-fix && ctest --test-dir build-fix --output-on-failure ``` It failed during CMake configure because `KDEGitCommitHooks.cmake` tried to write generated hooks under `.git/hooks`: `clang-format.sh.tmp` failed with `No such file or directory`, and `pre-commit.tmp` failed with `Read-only file system`. Narrow reproducible build/test from the same patched source copied without `.git` passed: ```sh srcdir=$(mktemp -d /tmp/yakuake-fix-src.XXXXXX) && builddir=$(mktemp -d /tmp/yakuake-fix-build.XXXXXX) && tar --exclude='./.git' --exclude='./build-fix' --exclude='./build-fix-nogit' -cf - . | tar -C "$srcdir" -xf - && cmake -S "$srcdir" -B "$builddir" -G Ninja && cmake --build "$builddir" --target yakuake && ctest --test-dir "$builddir" --output-on-failure ``` Result: `yakuake` built successfully and `appstreamtest` passed. Bounded runtime reproduction attempt: ```sh builddir=$(ls -td /tmp/yakuake-fix-build.* | head -n 1) && QT_QPA_PLATFORM=offscreen timeout 10s "$builddir/bin/yakuake" ``` Blocked before GUI focus handling: `DBus session bus not found`. Retrying with `dbus-run-session` also failed because the sandbox could not bind the D-Bus socket: `Operation not permitted`. Evidence confidence remains `observed`.
diff --git a/app/sessionstack.cpp b/app/sessionstack.cpp
index 0850720..2de2d28 100644
--- a/app/sessionstack.cpp
+++ b/app/sessionstack.cpp
@@ -110,8 +110,12 @@ void SessionStack::raiseSession(int sessionId)
 
     setCurrentWidget(session->widget());
 
-    if (session->widget()->focusWidget())
-        session->widget()->focusWidget()->setFocus();
+    Terminal *terminal = session->getTerminal(session->activeTerminalId());
+    if (terminal) {
+        QWidget *terminalWidget = terminal->terminalWidget();
+        if (terminalWidget)
+            terminalWidget->setFocus();
+    }
 
     if (session->hasTerminalsWithKeyboardInputDisabled())
         m_visualEventOverlay->show();

Technical snapshot

Fixer kept the most informative crashing thread and shows the top stack frames below.

Crashing thread stack trace

  • Process: yakuake
  • Signal: SEGV) si_code: SI_TKILL
  • Kernel: 7.1-amd64
  • Distribution: debian
__pthread_kill_implementation
__GI_raise
KCrash::defaultCrashHandler(int)
__restore_rt
QWidget::focusWidget() const
n/a
QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*)
QApplicationPrivate::notify_helper(QObject*, QEvent*)
QCoreApplication::notifyInternal2(QObject*, QEvent*)
QApplicationPrivate::setFocusWidget(QWidget*, Qt::FocusReason)
QWidget::setFocus(Qt::FocusReason)
QApplicationPrivate::setActiveWindow(QWidget*)
QApplicationPrivate::notifyActiveWindowChange(QWindow*)
QGuiApplicationPrivate::processFocusWindowEvent(QWindowSystemInterfacePrivate::FocusWindowEvent*)

Worker outcome summary

This issue has 1 recorded worker attempt. Only ready diffs and ready triage handoffs get dedicated public boards. Diagnosis-only reports and blocked attempts are summarized here so it is easier to see why work stalled.

1 ready patch attempts

No ready triage handoffs, diagnosis-only reports, failed patch attempts, explained impossible attempts, or other attempt states.

Published attempts

ready patch attempt

patch

Patch proposal created locally. Review it and submit it upstream if it looks correct.

state: readycreated: 2026-07-09 15:33 UTCvalidation: ready
Published session

Prompt

## Plan Pass

You are planning a fixer patch before any edits happen.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-source`. The original pre-edit snapshot is available at `./source` if you need to inspect it.

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `cmake -S . -B build-fix -G Ninja && cmake --build build-fix && ctest --test-dir build-fix --output-on-failure`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. For public upstream review, prepare the final patch against the upstream default integration branch, usually `master` or `main`; use installed or stable source trees for reproduction/backport validation, not as the default merge-request base unless the contribution docs explicitly say to target a stable branch. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, branch-base choice, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `yakuake` upstream patch, not just a Debian-local workaround. Inspect the relevant code, nearby callers, project contribution docs, and local helper/compat APIs, but do not edit files in this pass.

Return a short markdown plan with these exact sections:

## Problem
## Evidence Confidence
## Proposed Subject
## Patch Plan
## Risks
## Validation

Classify `## Evidence Confidence` as exactly one of `reproduced`, `observed`, or `inferred`. Use `inferred` only for a no-patch diagnosis/report plan unless you can name the extra evidence you will collect before editing; inferred source patches are blocked by Fixer because they are not pull-request-ready. For `observed` source-patch plans, plan to say in the final `## Issue Connection` that the failure was observed by Fixer and not independently reproduced. If the plan touches authentication, authorization, credentials, cryptography, sandboxing, permissions, timing/throttling behavior, or PostgreSQL database-core behavior such as dynamic library resolution, extension loading, transaction semantics, locking, planner/executor behavior, catalog changes, or storage changes, treat it as high-risk: do not plan a source patch unless validation can reproduce the behavior and analyze the semantic impact; otherwise plan a no-patch diagnosis/report. The plan must explain how the proposed code change addresses the observed issue evidence, call out any prior Fixer patch that should be improved or replaced, reject awkward control flow such as avoidable `goto` if there is a cleaner bounded alternative, name any local helper APIs or maintainer conventions the patch should follow, and keep the intended maintainer-facing explanation clear enough that someone unfamiliar with the local complaint wording can still follow the fix. In `## Validation`, name the reproducible configure/build/test entrypoint you will try from the workspace root before any focused leaf compile or smoke check, and include one bounded independent reproduction attempt for the collected failure signal when it is safe and cheap. Do not plan to claim `reproduced` unless that reproduction command or test can actually show the failure.

## Patch Pass

You are working on a bounded fixer proposal.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-source`. Produce the smallest reasonable patch for the target repository, keep the change upstreamable, prefer the clearest control flow available, and do not keep avoidable `goto` when a simpler structure would read better. Before introducing new file, process, allocation, locking, networking, or platform APIs, inspect nearby code and project contribution docs for existing helpers or compatibility wrappers and use those local patterns unless you can explain why they do not fit. Validate from a reproducible workspace-root entrypoint before falling back to focused leaf commands; if a build or test cannot run, report the exact command, the exact blocker, and any narrower check you ran instead. During validation, also try one bounded independent reproduction of the collected failure signal when it is safe and cheap, such as a failing test, smoke command, perf/strace comparison, or before/after runtime check. Only use `reproduced` if that command or test actually reproduced the failure; otherwise keep `observed` and report the reproduction blocker. The final explanation must connect the observed issue evidence to the actual code change, not just paraphrase the diff. Write like a maintainer is going to read the patch mail cold: explain the bug in plain language, define subsystem-specific jargon the first time you need it, and make the causal story obvious. Explicitly classify evidence confidence as `reproduced`, `observed`, or `inferred`: `reproduced` means you reproduced the failure locally; `observed` means Fixer has direct crash/log/trace evidence but you did not independently reproduce it; `inferred` means the source patch is not pull-request-ready, so do not leave a source diff unless you first gather stronger observed/reproduced evidence; otherwise return a no-patch diagnosis/report. For any source-changing `observed` patch, say explicitly in `## Issue Connection` that the failure was observed by Fixer and not independently reproduced. Security-sensitive areas such as authentication, authorization, credentials, cryptography, sandboxing, permissions, and timing/throttling behavior need reproduced evidence plus explicit security-impact analysis before leaving a source diff; otherwise return a no-patch diagnosis/report for human review. If you introduce non-obvious state translation, index remapping, or backend split logic, add a short source comment that explains the invariant being preserved.

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `cmake -S . -B build-fix -G Ninja && cmake --build build-fix && ctest --test-dir build-fix --output-on-failure`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. For public upstream review, prepare the final patch against the upstream default integration branch, usually `master` or `main`; use installed or stable source trees for reproduction/backport validation, not as the default merge-request base unless the contribution docs explicitly say to target a stable branch. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, branch-base choice, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `yakuake` upstream patch, not just a Debian-local workaround. 

Keep the change narrowly scoped and summarize validation clearly.

In every authoring pass, your final response must start with `Subject: <single-line git commit subject>` and then include these markdown sections exactly:

## Commit Message
A short upstream-friendly explanation of what changed and why. Write it in plain language that a maintainer can follow without local complaint context. If you use subsystem jargon, define it immediately.

## Evidence Confidence
Exactly one word: `reproduced`, `observed`, or `inferred`. Use `reproduced` only when you reproduced the failure locally with a command or test, and include that command/test in `## Validation`. Use `observed` when Fixer has direct crash/log/trace evidence but you did not independently reproduce it. If `## Git Add Paths` lists source files for an `observed` patch, `## Issue Connection` must explicitly say the failure was observed by Fixer and not independently reproduced. Security-sensitive source changes touching authentication, authorization, credentials, cryptography, sandboxing, permissions, or timing/throttling behavior require reproduced evidence and explicit security-impact analysis. PostgreSQL database-core source changes touching dynamic library resolution, extension loading, transaction semantics, locking, planner/executor behavior, catalog changes, or storage changes require reproduced evidence plus explicit semantic-impact analysis. Otherwise list `None` under `## Git Add Paths` and write a no-patch diagnosis/report. Use `inferred` for profiler/strace/indirect evidence; inferred responses may be no-patch diagnoses or reports, but inferred source patches are not pull-request-ready until stronger evidence is gathered.

## Issue Connection
Write this as maintainer-facing patch mail, not as local Fixer notes. Cover four things explicitly in readable sentences: the user-visible symptom or the exact collected signal, the code-level cause or the cautious inference from evidence, the specific change you made, and the expected effect. Do not invent a reproducer, command line, crash, or user-visible failure that is not present in the evidence bundle. If the evidence is direct-but-not-reproduced, say it was observed by Fixer and not independently reproduced. If the evidence is indirect and you did not gather stronger evidence, do not leave a source diff; write a no-patch diagnosis/report instead. Include an explicit effect sentence such as `The expected effect is ...`, `This should reduce ...`, or `This prevents ...` for source patches. If the logic is non-obvious in code, mention that you added a short explanatory comment.

## Git Add Paths
List the repo-relative paths that belong in the final patch, one per line. Use `None` only when you intentionally made no source changes. Include intentionally new files, and do not list generated build artifacts.

## Validation
List the checks you ran, or say clearly that you could not run them. Include the independent reproduction command/test and result when `## Evidence Confidence` is `reproduced`; if reproduction was attempted but blocked, name the exact blocker and keep confidence at `observed` or `inferred`.

Before editing, read the plan at `./plan-output.txt` and follow it unless the code proves part of it wrong. If you change course, say so explicitly in the final write-up instead of silently drifting from the plan.

## Review Pass 1

You are reviewing a freshly generated fixer patch.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-source`. Review the first patch pass. The original pre-edit snapshot is available at `./source` for diffing. The workspace currently changes these repo-relative paths: app/sessionstack.cpp. Verify that `## Git Add Paths` matches this exact set and that `## Issue Connection` explains every shipped functional file.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. For public upstream review, prepare the final patch against the upstream default integration branch, usually `master` or `main`; use installed or stable source trees for reproduction/backport validation, not as the default merge-request base unless the contribution docs explicitly say to target a stable branch. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, branch-base choice, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `yakuake` upstream patch, not just a Debian-local workaround.

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `cmake -S . -B build-fix -G Ninja && cmake --build build-fix && ctest --test-dir build-fix --output-on-failure`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout. The latest author response is at `./patch-output.txt`. Inspect the current code and changed paths like a strict code reviewer. Focus on correctness, regressions, maintainability, awkward control flow such as avoidable `goto`, missing validation, weak or non-gittable commit message text, and explanations that fail to connect the observed issue evidence to the code change. Also review the maintainer experience: the patch mail should be easy to accept upstream, the user-visible bug should be explained in plain language, subsystem-specific jargon should be defined when first used, and any non-obvious state translation or index remapping in code should have a short explanatory comment. Reject patches that omit `## Evidence Confidence`, use anything other than `reproduced`, `observed`, or `inferred`, or sound more certain than that evidence level allows. Reject patches that claim `reproduced` unless `## Validation` names the concrete reproduction command or test and its result. Reject source patches in security-sensitive areas such as authentication, authorization, credentials, cryptography, sandboxing, permissions, and timing/throttling behavior unless the author reproduced the behavior and explicitly analyzed the security impact of the change; observed-only evidence should become a diagnosis/report, not a PR-ready source diff. Reject patches that invent a reproducer, command line, crash, or user-visible failure not present in the evidence bundle; indirect profiler or strace evidence may justify a cautious mitigation, but the author must say it is indirect instead of presenting it as a confirmed upstream bug. Reject patches that introduce generic libc/std APIs when nearby code or project docs provide a local compat/helper API for the same job, unless the author explicitly justifies the exception. Reject validation that only reports a leaf object/syntax build when a project-level configure/build/test entrypoint exists and was not attempted; if a full build cannot run, the author must show the exact failed command and blocker.

Do not apply code changes in this pass.

Return a short markdown review report. The first non-empty line must be exactly one of:

RESULT: ok
RESULT: fix-needed

If you choo

[truncated 11132 bytes]

Response

## Plan Pass

## Problem
Yakuake crashed during Qt focus handling. The captured stack shows `QWidget::focusWidget()` followed by yakuake frames during a `FocusIn`/event-filter signal cascade. The clearest local suspect is `SessionStack::raiseSession()`, which calls `session->widget()->focusWidget()` twice after `setCurrentWidget()` and can be reached from activation paths.

## Evidence Confidence
observed

## Proposed Subject
Avoid repeated focus-chain lookup when raising sessions

## Patch Plan
Target upstream `master` style; the workspace branch is `master`, and README points to KDE upstream sources with standard CMake build instructions. No separate `CONTRIBUTING`, `HACKING`, `docs/`, or custom IO/process/logging/platform helper wrappers were found; follow existing direct Qt/KF style.

Patch `SessionStack::raiseSession()` to store the result of `session->widget()->focusWidget()` in a local `QPointer<QWidget>` or plain checked pointer and call `setFocus()` only once if still valid. This directly addresses the observed crash site by reducing repeated focus-chain traversal during a re-entrant focus change. No `goto` or broad control-flow change is needed.

Also add defensive checks in nearby focus restoration only if inspection shows the same repeated unsafe pattern with no behavior change. No prior Fixer patch was found to replace or improve.

## Risks
This is GUI focus behavior, so the main risk is subtly changing which terminal receives focus when switching tabs/sessions. Keep the change narrow: preserve existing focus target and timing, only avoid duplicate lookup/use.

The evidence is a coredump, not a deterministic reproducer, so the final patch must say the crash was observed by Fixer and not independently reproduced.

## Validation
First try the project entrypoint from the workspace root:

```sh
cmake -S . -B build-fix -G Ninja && cmake --build build-fix && ctest --test-dir build-fix --output-on-failure
```

If that fails due to missing KDE/Qt/Konsole build dependencies or generated files, report the exact command and failure reason, then run the narrowest reproducible compile such as:

```sh
cmake --build build-fix --target yakuake
```

Bounded independent signal check: after build, attempt a cheap GUI startup smoke test under an isolated platform setting, for example:

```sh
QT_QPA_PLATFORM=offscreen timeout 10s ./build-fix/app/yakuake
```

Do not claim reproduction unless that command actually triggers the original focus crash.

## Patch Pass

Subject: Avoid repeated focus-chain lookup when raising sessions

## Commit Message
When raising a session, reuse the focused child widget instead of asking Qt for it twice. This keeps the existing focus behavior but avoids a second focus-chain lookup while session switching may already be happening inside Qt focus event handling.

## Evidence Confidence
observed

## Issue Connection
Fixer observed a Yakuake SIGSEGV in a coredump from `/usr/bin/yakuake`; the stack entered `QWidget::focusWidget()` during Qt focus-event processing. I did not independently reproduce that crash.

The cautious code-level connection is that `SessionStack::raiseSession()` changed the current stacked widget and then called `session->widget()->focusWidget()` twice before setting focus. The focus chain is Qt’s record of which child widget currently owns focus inside a parent widget; asking for it repeatedly during focus activation can re-enter fragile state unnecessarily.

The patch stores the focused child in a local `QWidget *` and calls `setFocus()` on that saved pointer. The expected effect is to preserve the same focus target while avoiding the duplicate focus-chain traversal adjacent to the observed crash path.

## Git Add Paths
app/sessionstack.cpp

## Validation
Checked contribution/style context before editing: only `README.md` was present among the requested docs, and it describes standard KDE CMake build flow. The workspace branch is `master`. I found no relevant local helper wrapper for this GUI focus path; nearby code uses direct Qt/KF APIs.

Required project-level command attempted from workspace root:

```sh
cmake -S . -B build-fix -G Ninja && cmake --build build-fix && ctest --test-dir build-fix --output-on-failure
```

It failed during CMake configure because `KDEGitCommitHooks.cmake` tried to write generated hooks under `.git/hooks`: `clang-format.sh.tmp` failed with `No such file or directory`, and `pre-commit.tmp` failed with `Read-only file system`.

Narrow reproducible build/test from the same patched source copied without `.git` passed:

```sh
srcdir=$(mktemp -d /tmp/yakuake-fix-src.XXXXXX) && builddir=$(mktemp -d /tmp/yakuake-fix-build.XXXXXX) && tar --exclude='./.git' --exclude='./build-fix' --exclude='./build-fix-nogit' -cf - . | tar -C "$srcdir" -xf - && cmake -S "$srcdir" -B "$builddir" -G Ninja && cmake --build "$builddir" --target yakuake && ctest --test-dir "$builddir" --output-on-failure
```

Result: `yakuake` built successfully and `appstreamtest` passed.

Bounded runtime reproduction attempt:

```sh
builddir=$(ls -td /tmp/yakuake-fix-build.* | head -n 1) && QT_QPA_PLATFORM=offscreen timeout 10s "$builddir/bin/yakuake"
```

Blocked before GUI focus handling: `DBus session bus not found`. Retrying with `dbus-run-session` also failed because the sandbox could not bind the D-Bus socket: `Operation not permitted`. Evidence confidence remains `observed`.

## Review Pass 1

RESULT: fix-needed

## Findings
- `app/sessionstack.cpp:113`: The patch does not convincingly address the observed crash. The coredump shows a crash inside `QWidget::focusWidget()`, and the changed code still calls `session->widget()->focusWidget()` on the same object in the same code path. The review explanation says the problem is “asking for it repeatedly during focus activation,” but there is no event processing or re-entrant call between the original first and second `focusWidget()` calls; the only behavior change is removing a duplicate getter call. Please either gather stronger evidence that the crashing instruction was specifically the second lookup, or change the patch to avoid the fragile lookup entirely using an existing, better-owned focus target if the subsystem provides one.

- `## Issue Connection`: The maintainer-facing explanation overstates the causal link for `observed` evidence. It presents the duplicate lookup as the crash-adjacent mechanism, but the evidence only identifies `QWidget::focusWidget()` somewhere in unsymbolized yakuake focus handling. Because the crash was not reproduced and the yakuake frames are unresolved, the final explanation should stay at “targeted mitigation” level unless additional symbolization/reproduction ties the stack to this exact call site and failure mode.

## Refinement Pass 1

Subject: Focus raised sessions through their active terminal

## Commit Message
When raising a session, focus the session’s tracked active terminal widget directly instead of asking Qt to rediscover the focused child through `QWidget::focusWidget()`. Yakuake already tracks the active terminal for each session, and using that stored terminal widget keeps the intended focus behavior while avoiding a fragile focus-chain lookup during session switching.

## Evidence Confidence
observed

## Issue Connection
Fixer observed a Yakuake SIGSEGV in a coredump from `/usr/bin/yakuake`; the stack entered `QWidget::focusWidget()` while Qt was processing focus events. I did not independently reproduce that crash.

The cautious code-level connection is that `SessionStack::raiseSession()` used `session->widget()->focusWidget()` immediately after changing the current stacked widget. The focus chain is Qt’s record of which child widget currently owns focus inside a parent widget. In this path Yakuake does not need Qt to rediscover that child: the `Session` already records its active `Terminal`, and `Terminal::terminalWidget()` is a guarded pointer to the embedded terminal widget.

The patch changes `raiseSession()` to fetch the active terminal via `session->getTerminal(session->activeTerminalId())` and focus that terminal widget if it still exists. This addresses the review finding by avoiding the `focusWidget()` call entirely in this path, rather than just reducing duplicate calls. The expected effect is to preserve session-raise focus behavior while avoiding the crash-adjacent Qt focus-chain lookup.

## Git Add Paths
app/sessionstack.cpp

## Validation
Checked contribution/style context before editing: only `README.md` was present among the requested docs, and it describes standard KDE CMake build flow. The workspace branch is `master`. I found no relevant local helper wrapper for this GUI focus path; nearby code uses direct Qt/KF APIs and already uses `Session::getTerminal()`, `Session::activeTerminalId()`, and `Terminal::terminalWidget()` for focus restoration.

Required project-level command attempted from workspace root:

```sh
cmake -S . -B build-fix -G Ninja && cmake --build build-fix && ctest --test-dir build-fix --output-on-failure
```

It failed during CMake configure because `KDEGitCommitHooks.cmake` tried to write generated hooks under `.git/hooks`: `clang-format.sh.tmp` failed with `No such file or directory`, and `pre-commit.tmp` failed with `Read-only file system`.

Narrow reproducible build/test from the same patched source copied without `.git` passed:

```sh
srcdir=$(mktemp -d /tmp/yakuake-fix-src.XXXXXX) && builddir=$(mktemp -d /tmp/yakuake-fix-build.XXXXXX) && tar --exclude='./.git' --exclude='./build-fix' --exclude='./build-fix-nogit' -cf - . | tar -C "$srcdir" -xf - && cmake -S "$srcdir" -B "$builddir" -G Ninja && cmake --build "$builddir" --target yakuake && ctest --test-dir "$builddir" --output-on-failure
```

Result: `yakuake` built successfully and `appstreamtest` passed.

Bounded runtime reproduction attempt:

```sh
builddir=$(ls -td /tmp/yakuake-fix-build.* | head -n 1) && QT_QPA_PLATFORM=offscreen timeout 10s "$builddir/bin/yakuake"
```

Blocked before GUI focus handling: `DBus session bus not found`. Retrying with `dbus-run-session` also failed because the sandbox could not bind the D-Bus socket: `Operation not permitted`. Evidence confidence remains `observed`.

## Review Pass 2

RESULT: ok

Diff

diff --git a/app/sessionstack.cpp b/app/sessionstack.cpp
index 0850720..2de2d28 100644
--- a/app/sessionstack.cpp
+++ b/app/sessionstack.cpp
@@ -110,8 +110,12 @@ void SessionStack::raiseSession(int sessionId)
 
     setCurrentWidget(session->widget());
 
-    if (session->widget()->focusWidget())
-        session->widget()->focusWidget()->setFocus();
+    Terminal *terminal = session->getTerminal(session->activeTerminalId());
+    if (terminal) {
+        QWidget *terminalWidget = terminal->terminalWidget();
+        if (terminalWidget)
+            terminalWidget->setFocus();
+    }
 
     if (session->hasTerminalsWithKeyboardInputDisabled())
         m_visualEventOverlay->show();