https://bugs.kde.org/show_bug.cgi?id=523770

--- Comment #4 from Zamundaaa <[email protected]> ---
Git commit 2a05bf210c256b4aea2ca0cfbf4596fce36dcf21 by Xaver Hugl, on behalf of
Sebastian Müller.
Committed on 25/08/2026 at 20:44.
Pushed by zamundaaa into branch 'master'.

input: iterate over a copy when dispatching to filters and spies

A filter may uninstall and delete itself while it handles an event.
DpmsInputEventFilter does whenever it wakes the outputs up: notify() leads
to Workspace::requestDpmsState(On), which resets Workspace::m_dpmsFilter,
and ~InputEventFilter removes the filter from m_filters. Both dispatch
loops iterated over the member lists themselves, so the container was
modified underneath them.

For filters this stays benign as long as the handler returns true, which
ends the loop right away - except for switchEvent(), which calls notify()
on a lid switch and then returns false, letting the loop continue over an
already modified list and skip a filter. Spies return void, so their loop
always carries on.

Iterate over a copy instead, so the loop stays valid when the list shrinks
underneath it. The handler's own pointer is never touched again after the
call, so this is safe under the assumption that a handler only ever
deletes itself, not other filters or spies - which holds for everything in
the tree today.

M  +10   -2    src/input.h

https://invent.kde.org/plasma/kwin/-/commit/2a05bf210c256b4aea2ca0cfbf4596fce36dcf21

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to