BUG:366713 Fix using the temporary target
A line like
QRect rect = temporaryTarget() ? temporaryTarget()->extent() : QRect();
is dangerous, since the paint device might be gone between the check
and the use. It's better to get a local shared pointer to the paint
device and check that.