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

Allen Winter <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Latest Commit|https://invent.kde.org/pim/ |https://invent.kde.org/pim/
                   |kdepim-runtime/-/commit/222 |kdepim-runtime/-/commit/c53
                   |3be6dfadcfff0e000538f6c9e5f |2df0774c3b0982f56a81b04ceb7
                   |15e040077d                  |b9f6895ee8

--- Comment #2 from Allen Winter <[email protected]> ---
Git commit c532df0774c3b0982f56a81b04ceb7b9f6895ee8 by Allen Winter.
Committed on 12/11/2026 at 15:10.
Pushed by winterz into branch 'release/26.12'.

Destroy the EWS subscription manager before the other resource members

`EwsResource` now tears down its subscription manager before any other member
is
destroyed. Nothing else changes.

**What and why**

`EwsResource` declares `QScopedPointer<EwsSubscriptionManager> mSubManager`
(`resources/ews/ewsresource.h:169`) before `QScopedPointer<EwsSettings>
mSettings`
(`resources/ews/ewsresource.h:181` before this change, 183 after). Members are
destroyed in
reverse declaration order, so the settings are freed first and the subscription
manager
second, and `~EwsSubscriptionManager()` calls `cancelSubscription()`, which
dereferences
`mSettings` (a raw `EwsSettings *`, not a `QPointer`) to read
`eventSubscriptionId()`,
clear it and call `save()`.

Chain: `mSettings` is destroyed before `mSubManager` ->
`~EwsSubscriptionManager()` reads and
saves `mSettings` -> use-after-free when the agent stops.

Only `doSetOnline(false)` (`resources/ews/ewsresource.cpp:1243-1249`) and
`reloadConfig()`
(`resources/ews/ewsresource.cpp:436-442`) used to reset the manager before
teardown, and
Akonadi's `AgentBase::quit()` does not go offline, so a normal agent stop
reaches the
destructor with the manager still alive.

**How**

`~EwsResource()` (`resources/ews/ewsresource.cpp:131`) now has a real body that
calls
`mSubManager.reset()` before any member is destroyed, plus a comment at the
declaration
documenting the dependency on `mSettings`. The declaration order is
deliberately left
alone: with the explicit reset it no longer matters, and reordering would only
widen the
diff.

**Verification**

- `prek run --files resources/ews/ewsresource.cpp resources/ews/ewsresource.h`:
all hooks
  pass, including clang-format with the project's own configuration and
codespell.
- No full build locally: the machine where this was written has no dev output
for kdav
  (`KF6DAVConfig.cmake` is missing), so kdepim-runtime cannot be configured
there. CI is
  the first real build of this change.
- No unit test: constructing an `EwsResource` needs a live Akonadi/D-Bus
session and an
  agent config, while the existing EWS unit tests only build isolated jobs.


(cherry picked from commit 2223be6dfadcfff0e000538f6c9e5f15e040077d)

339fcbe8 Destroy the EWS subscription manager before the other resource members

Co-authored-by: Sergey Kostyuchenko <[email protected]>

M  +7    -1    resources/ews/ewsresource.cpp
M  +2    -0    resources/ews/ewsresource.h

https://invent.kde.org/pim/kdepim-runtime/-/commit/c532df0774c3b0982f56a81b04ceb7b9f6895ee8

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

Reply via email to