Skip to content
Commit 113dc510 authored by Harald Sitter's avatar Harald Sitter 🐧
Browse files

allow pulsesupport to return null on instance requests

it can happen that we destruct our factory (and along with it all backend
objects and pulsesupport) before all frontend classes have been
deleted. most notably this currently happens with knotifications that
old the frontend objects in a q_global_static that is only cleaned up
in the applications' exit handler. at that point our frontend class
would then try to access an already destructed pulsesupport and causing
a dummy instance to be created which ultimately didn't do anything anyway.

to prevent this from happen pulsesupport now has a new getInstanceOrNull
which can be explicitly instructed to return null iff the instance
was already shut down, since this now requires explicit nullptr handling
this new functionality is separate from the regular getInstance which
always returns a valid pointer (albeit sometimes to a dummy instance).

this new getInstanceOrNull function is used in our frontend audiooutput
to prevent dummy creation on destruction. since the AO only clears the
phonon internal stream cache (mapping AOs to pulse stream ids) we do not
have to do this if the instance has already been shut down anyway
ultimately making this part of the code non-essential.

(random related note: phonon's factory cleans up on qapplication
 destruction, so we can safely assume that consumers will not try to
 actively use our classes past this point, and if they do it's really their
 fault if something goes wrong)

CCMAIL: martin.klapetek@gmail.com
CCMAIL: kde-multimedia@kde.org
parent c80d04ce
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