qml: add backend task outcomes and cancellation

bitcoin-core/gui-qml: PR #1109

1 suggestion

Optional improvements

Link

[suggestion] · Blocking on drain inside a task completion deadlocks

A submitTask completion that synchronously waits for its own executor to drain deadlocks, even with a nested event loop; no production caller currently uses this API, but its contract omits the restriction.

Location: qml/backendexecutor.cpp:82 (head).

Details and suggested fix

complete() increments active_callbacks before invoking the completion and decrements it only after the completion returns. finishShutdownIfReady() refuses to schedule final worker cleanup and thread exit while that count is nonzero. Calling shutdown() and then waiting for isDrained() inside the completion therefore waits for an event that requires the same completion to return. This also applies indirectly through an owner's blocking destructor, such as the pattern in ~OptionsQmlModel, which currently uses legacy submit(). Document that submitTask completions must not synchronously wait for their own executor to drain, including through owner destruction. Keep the callback gate because it preserves cleanup ordering; any future blocking-drain helper should assert against this use.


Coverage details