D26267: Replace deprecated QWeakPointer::data() with .toStrongRef().data()
Anthony Fieroni
noreply at phabricator.kde.org
Sun Dec 29 08:24:09 GMT 2019
anthonyfieroni added a comment.
`auto c = client().toStrongRef().data();`
This is completely wrong, the idea behind shared / weak pointer is ability to know when non-owning resource goes out of scope. by calling toStrongRef you extend its lifetime if and only if it exists at time of call then holding this ref you ensure that resource will not be destroyed meanwhile. By holding data() it does nothing to extend resource lifetime but getting a pointer to well-known dying object. It should be
`auto c = m_decoration.data()->client().toStrongRef();`
Last but not least, c can be nullptr check against null should be performed as well. Exp
xcb_window_t windowId;
auto c = m_decoration.data()->client().toStrongRef();
if (c && (windowId = c->windowId())) {
} else {
hide();
}
It should be added checks in all use places.
REPOSITORY
R31 Breeze
REVISION DETAIL
https://phabricator.kde.org/D26267
To: ndavis, #breeze, #plasma
Cc: anthonyfieroni, plasma-devel, LeGast00n, The-Feren-OS-Dev, jraleigh, zachus, fbampaloukas, GB_2, ragreen, ZrenBot, ngraham, alexeymin, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, ahiemstra, mart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20191229/dfe0c3e1/attachment.html>
More information about the Plasma-devel
mailing list