wayland: Remove QPointer from public SurfaceInterface api

QPointer is not meant for return values. There are also performance
considerations to avoid returning QPointer.
This commit is contained in:
Vlad Zahorodnii 2023-09-07 13:56:54 +03:00
parent dcadf24e64
commit a51277f88a
15 changed files with 37 additions and 21 deletions

View file

@ -7,6 +7,7 @@
#include "display.h"
#include "surface_interface.h"
#include <QPointer>
#include <QtGlobal>
#include "qwayland-server-appmenu.h"

View file

@ -252,7 +252,7 @@ void ShadowTest::testSurfaceDestroy()
// destroy the parent surface
QSignalSpy surfaceDestroyedSpy(serverSurface, &QObject::destroyed);
QSignalSpy shadowDestroyedSpy(serverShadow.data(), &QObject::destroyed);
QSignalSpy shadowDestroyedSpy(serverShadow, &QObject::destroyed);
surface.reset();
QVERIFY(surfaceDestroyedSpy.wait());
QVERIFY(shadowDestroyedSpy.isEmpty());

View file

@ -149,7 +149,7 @@ void TestBlur::testCreate()
QCOMPARE(serverSurface->blur()->region(), QRegion(0, 0, 10, 20));
// and destroy
QSignalSpy destroyedSpy(serverSurface->blur().data(), &QObject::destroyed);
QSignalSpy destroyedSpy(serverSurface->blur(), &QObject::destroyed);
delete blur;
QVERIFY(destroyedSpy.wait());
}
@ -174,7 +174,7 @@ void TestBlur::testSurfaceDestroy()
// destroy the parent surface
QSignalSpy surfaceDestroyedSpy(serverSurface, &QObject::destroyed);
QSignalSpy blurDestroyedSpy(serverSurface->blur().data(), &QObject::destroyed);
QSignalSpy blurDestroyedSpy(serverSurface->blur(), &QObject::destroyed);
surface.reset();
QVERIFY(surfaceDestroyedSpy.wait());
QVERIFY(blurDestroyedSpy.isEmpty());

View file

@ -161,7 +161,7 @@ void TestContrast::testCreate()
QCOMPARE(wl_fixed_from_double(serverSurface->contrast()->saturation()), wl_fixed_from_double(1.7));
// and destroy
QSignalSpy destroyedSpy(serverSurface->contrast().data(), &QObject::destroyed);
QSignalSpy destroyedSpy(serverSurface->contrast(), &QObject::destroyed);
delete contrast;
QVERIFY(destroyedSpy.wait());
}
@ -186,7 +186,7 @@ void TestContrast::testSurfaceDestroy()
// destroy the parent surface
QSignalSpy surfaceDestroyedSpy(serverSurface, &QObject::destroyed);
QSignalSpy contrastDestroyedSpy(serverSurface->contrast().data(), &QObject::destroyed);
QSignalSpy contrastDestroyedSpy(serverSurface->contrast(), &QObject::destroyed);
surface.reset();
QVERIFY(surfaceDestroyedSpy.wait());
QVERIFY(contrastDestroyedSpy.isEmpty());

View file

@ -150,7 +150,7 @@ void TestSlide::testCreate()
QCOMPARE(serverSurface->slideOnShowHide()->offset(), 15);
// and destroy
QSignalSpy destroyedSpy(serverSurface->slideOnShowHide().data(), &QObject::destroyed);
QSignalSpy destroyedSpy(serverSurface->slideOnShowHide(), &QObject::destroyed);
delete slide;
QVERIFY(destroyedSpy.wait());
}
@ -170,11 +170,11 @@ void TestSlide::testSurfaceDestroy()
surface->commit(KWayland::Client::Surface::CommitFlag::None);
QVERIFY(slideChanged.wait());
auto serverSlide = serverSurface->slideOnShowHide();
QVERIFY(!serverSlide.isNull());
QVERIFY(serverSlide);
// destroy the parent surface
QSignalSpy surfaceDestroyedSpy(serverSurface, &QObject::destroyed);
QSignalSpy slideDestroyedSpy(serverSlide.data(), &QObject::destroyed);
QSignalSpy slideDestroyedSpy(serverSlide, &QObject::destroyed);
surface.reset();
QVERIFY(surfaceDestroyedSpy.wait());
QVERIFY(slideDestroyedSpy.isEmpty());

View file

@ -9,6 +9,8 @@
#include "qwayland-server-content-type-v1.h"
#include <QPointer>
namespace KWaylandServer
{

View file

@ -5,13 +5,14 @@
*/
#include "keyboard_shortcuts_inhibit_v1_interface.h"
#include <qwayland-server-keyboard-shortcuts-inhibit-unstable-v1.h>
#include "display.h"
#include "seat_interface.h"
#include "surface_interface.h"
#include <qwayland-server-keyboard-shortcuts-inhibit-unstable-v1.h>
#include <QPointer>
static const int s_version = 1;
namespace KWaylandServer

View file

@ -11,6 +11,8 @@
#include <qwayland-server-plasma-shell.h>
#include <QPointer>
namespace KWaylandServer
{
static const quint32 s_version = 8;

View file

@ -14,6 +14,7 @@
#include <QHash>
#include <QIcon>
#include <QList>
#include <QPointer>
#include <QRect>
#include <QThreadPool>
#include <QUuid>

View file

@ -5,9 +5,10 @@
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "surface_interface.h"
#include "blur_interface.h"
#include "clientconnection.h"
#include "compositor_interface.h"
#include "contenttype_v1_interface.h"
#include "contrast_interface.h"
#include "display.h"
#include "fractionalscale_v1_interface_p.h"
#include "idleinhibit_v1_interface_p.h"
@ -15,6 +16,8 @@
#include "output_interface.h"
#include "pointerconstraints_v1_interface_p.h"
#include "region_interface_p.h"
#include "shadow_interface.h"
#include "slide_interface.h"
#include "subcompositor_interface.h"
#include "subsurface_interface_p.h"
#include "surface_interface_p.h"
@ -920,22 +923,22 @@ QRectF SurfaceInterface::boundingRect() const
return rect;
}
QPointer<ShadowInterface> SurfaceInterface::shadow() const
ShadowInterface *SurfaceInterface::shadow() const
{
return d->current->shadow;
}
QPointer<BlurInterface> SurfaceInterface::blur() const
BlurInterface *SurfaceInterface::blur() const
{
return d->current->blur;
}
QPointer<ContrastInterface> SurfaceInterface::contrast() const
ContrastInterface *SurfaceInterface::contrast() const
{
return d->current->contrast;
}
QPointer<SlideInterface> SurfaceInterface::slideOnShowHide() const
SlideInterface *SurfaceInterface::slideOnShowHide() const
{
return d->current->slide;
}

View file

@ -10,7 +10,6 @@
#include <QMatrix4x4>
#include <QObject>
#include <QPointer>
#include <QRegion>
struct wl_resource;
@ -196,22 +195,22 @@ public:
/**
* @returns The Shadow for this Surface.
*/
QPointer<ShadowInterface> shadow() const;
ShadowInterface *shadow() const;
/**
* @returns The Blur for this Surface.
*/
QPointer<BlurInterface> blur() const;
BlurInterface *blur() const;
/**
* @returns The Slide for this Surface.
*/
QPointer<SlideInterface> slideOnShowHide() const;
SlideInterface *slideOnShowHide() const;
/**
* @returns The Contrast for this Surface.
*/
QPointer<ContrastInterface> contrast() const;
ContrastInterface *contrast() const;
/**
* Whether the SurfaceInterface is currently considered to be mapped.

View file

@ -11,6 +11,7 @@
#include "utils.h"
// Qt
#include <QHash>
#include <QPointer>
#include <QVector>
// Wayland
#include "qwayland-server-wayland.h"

View file

@ -11,7 +11,9 @@
#include "utils.h"
#include "qwayland-server-tablet-unstable-v2.h"
#include <QHash>
#include <QPointer>
namespace KWaylandServer
{

View file

@ -10,6 +10,8 @@
#include "qwayland-server-wayland.h"
#include <QPointer>
namespace KWaylandServer
{
class ClientConnection;

View file

@ -11,6 +11,8 @@
#include "qwayland-server-xdg-activation-v1.h"
#include <QPointer>
namespace KWaylandServer
{
static const int s_version = 1;