Remove usage of QWeakPointer for QObject for thumbnails

Summary:
This usage of QWeakPointer has been deprecated since Qt 5.0, since it
leads to really confusing API - usually you must never dereference a
QWeakPointer directly, but always go through QSharedPointer, except in
this one case, where it's permissible.

The thumbnails are only referenced in one place, this change is straight-forward.

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23070
This commit is contained in:
Frederik Gladhorn 2019-08-10 13:31:49 +02:00
parent ef670c3648
commit 348232e682
3 changed files with 5 additions and 5 deletions

View file

@ -2063,9 +2063,9 @@ void EffectWindowImpl::insertThumbnail(WindowThumbnailItem *item)
{
EffectWindow *w = effects->findWindow(item->wId());
if (w) {
m_thumbnails.insert(item, QWeakPointer<EffectWindowImpl>(static_cast<EffectWindowImpl*>(w)));
m_thumbnails.insert(item, QPointer<EffectWindowImpl>(static_cast<EffectWindowImpl*>(w)));
} else {
m_thumbnails.insert(item, QWeakPointer<EffectWindowImpl>());
m_thumbnails.insert(item, QPointer<EffectWindowImpl>());
}
}

View file

@ -494,7 +494,7 @@ public:
QVariant data(int role) const override;
void registerThumbnail(AbstractThumbnailItem *item);
QHash<WindowThumbnailItem*, QWeakPointer<EffectWindowImpl> > const &thumbnails() const {
QHash<WindowThumbnailItem*, QPointer<EffectWindowImpl> > const &thumbnails() const {
return m_thumbnails;
}
QList<DesktopThumbnailItem*> const &desktopThumbnails() const {
@ -510,7 +510,7 @@ private:
Toplevel* toplevel;
Scene::Window* sw; // This one is used only during paint pass.
QHash<int, QVariant> dataMap;
QHash<WindowThumbnailItem*, QWeakPointer<EffectWindowImpl> > m_thumbnails;
QHash<WindowThumbnailItem*, QPointer<EffectWindowImpl> > m_thumbnails;
QList<DesktopThumbnailItem*> m_desktopThumbnails;
bool managed = false;
bool waylandClient;

View file

@ -509,7 +509,7 @@ static void adjustClipRegion(AbstractThumbnailItem *item, QRegion &clippingRegio
void Scene::paintWindowThumbnails(Scene::Window *w, QRegion region, qreal opacity, qreal brightness, qreal saturation)
{
EffectWindowImpl *wImpl = static_cast<EffectWindowImpl*>(effectWindow(w));
for (QHash<WindowThumbnailItem*, QWeakPointer<EffectWindowImpl> >::const_iterator it = wImpl->thumbnails().constBegin();
for (QHash<WindowThumbnailItem*, QPointer<EffectWindowImpl> >::const_iterator it = wImpl->thumbnails().constBegin();
it != wImpl->thumbnails().constEnd();
++it) {
if (it.value().isNull()) {