From fb81fe7a100b7ed9c620c38dbae1a14412805f2e Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 30 Mar 2020 17:24:21 +0200 Subject: [PATCH] Fix warnings Summary: Remove unused variables and members. We were often storing the q of classes without ever needing them. I'd just do it when it's useful. We do it in the private class so it can always be added, removes boilerplate code. Don't use std::move when returning temporary QImage. The compiler is smart enough to know to do it but produces the warning "moving a temporary object prevents copy elision". Remove unused lambda captured variables. Test Plan: Getting much cleaner build logs Reviewers: #frameworks, #kwin, zzag Reviewed By: #kwin, zzag Subscribers: zzag, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D28442 --- .../autotests/client/test_shm_pool.cpp | 2 - .../client/test_wayland_outputmanagement.cpp | 1 - .../autotests/client/test_wayland_shell.cpp | 2 +- src/wayland/display.cpp | 48 +++++++++---------- src/wayland/fakeinput_interface.cpp | 10 ++-- src/wayland/output_interface.cpp | 15 +++--- .../plasmavirtualdesktop_interface.cpp | 1 - .../plasmawindowmanagement_interface.cpp | 1 - src/wayland/server/buffer_interface.cpp | 14 +++--- .../server/eglstream_controller_interface.cpp | 4 +- src/wayland/server/textinput_interface_v0.cpp | 2 +- src/wayland/tests/shadowtest.cpp | 2 +- src/wayland/tests/touchclienttest.cpp | 2 +- src/wayland/tests/xdgforeigntest.cpp | 2 + 14 files changed, 50 insertions(+), 56 deletions(-) diff --git a/src/wayland/autotests/client/test_shm_pool.cpp b/src/wayland/autotests/client/test_shm_pool.cpp index 2aa1be97ef..2f544f47ed 100644 --- a/src/wayland/autotests/client/test_shm_pool.cpp +++ b/src/wayland/autotests/client/test_shm_pool.cpp @@ -37,7 +37,6 @@ private Q_SLOTS: private: KWayland::Server::Display *m_display; - KWayland::Server::CompositorInterface *m_compositorInterface; KWayland::Client::ConnectionThread *m_connection; KWayland::Client::Compositor *m_compositor; KWayland::Client::ShmPool *m_shmPool; @@ -49,7 +48,6 @@ static const QString s_socketName = QStringLiteral("kwin-test-wayland-surface-0" TestShmPool::TestShmPool(QObject *parent) : QObject(parent) , m_display(nullptr) - , m_compositorInterface(nullptr) , m_connection(nullptr) , m_compositor(nullptr) , m_shmPool(nullptr) diff --git a/src/wayland/autotests/client/test_wayland_outputmanagement.cpp b/src/wayland/autotests/client/test_wayland_outputmanagement.cpp index 6790ac62f9..d32644f9f6 100644 --- a/src/wayland/autotests/client/test_wayland_outputmanagement.cpp +++ b/src/wayland/autotests/client/test_wayland_outputmanagement.cpp @@ -71,7 +71,6 @@ private: QSignalSpy *m_announcedSpy; QSignalSpy *m_omSpy; - QSignalSpy *m_configSpy; }; static const QString s_socketName = QStringLiteral("kwin-test-wayland-output-0"); diff --git a/src/wayland/autotests/client/test_wayland_shell.cpp b/src/wayland/autotests/client/test_wayland_shell.cpp index c48cbf3248..e8b46a55a5 100644 --- a/src/wayland/autotests/client/test_wayland_shell.cpp +++ b/src/wayland/autotests/client/test_wayland_shell.cpp @@ -879,7 +879,7 @@ void TestWaylandShell::testClientDisconnecting() QVERIFY(serverShellSurface2); connect(serverShellSurface, &Resource::unbound, this, - [serverShellSurface, serverShellSurface2] { + [serverShellSurface2] { serverShellSurface2->requestSize(QSize(100, 200)); } ); diff --git a/src/wayland/display.cpp b/src/wayland/display.cpp index 2845e760c3..3592db170c 100644 --- a/src/wayland/display.cpp +++ b/src/wayland/display.cpp @@ -244,14 +244,14 @@ OutputInterface *Display::createOutput(QObject *parent) CompositorInterface *Display::createCompositor(QObject *parent) { CompositorInterface *compositor = new CompositorInterface(this, parent); - connect(this, &Display::aboutToTerminate, compositor, [this,compositor] { delete compositor; }); + connect(this, &Display::aboutToTerminate, compositor, [compositor] { delete compositor; }); return compositor; } ShellInterface *Display::createShell(QObject *parent) { ShellInterface *shell = new ShellInterface(this, parent); - connect(this, &Display::aboutToTerminate, shell, [this,shell] { delete shell; }); + connect(this, &Display::aboutToTerminate, shell, [shell] { delete shell; }); return shell; } @@ -267,7 +267,7 @@ OutputDeviceInterface *Display::createOutputDevice(QObject *parent) OutputManagementInterface *Display::createOutputManagement(QObject *parent) { OutputManagementInterface *om = new OutputManagementInterface(this, parent); - connect(this, &Display::aboutToTerminate, om, [this,om] { delete om; }); + connect(this, &Display::aboutToTerminate, om, [om] { delete om; }); return om; } @@ -275,7 +275,7 @@ SeatInterface *Display::createSeat(QObject *parent) { SeatInterface *seat = new SeatInterface(this, parent); connect(seat, &QObject::destroyed, this, [this, seat] { d->seats.removeAll(seat); }); - connect(this, &Display::aboutToTerminate, seat, [this,seat] { delete seat; }); + connect(this, &Display::aboutToTerminate, seat, [seat] { delete seat; }); d->seats << seat; return seat; } @@ -283,91 +283,91 @@ SeatInterface *Display::createSeat(QObject *parent) SubCompositorInterface *Display::createSubCompositor(QObject *parent) { auto c = new SubCompositorInterface(this, parent); - connect(this, &Display::aboutToTerminate, c, [this,c] { delete c; }); + connect(this, &Display::aboutToTerminate, c, [c] { delete c; }); return c; } DataDeviceManagerInterface *Display::createDataDeviceManager(QObject *parent) { auto m = new DataDeviceManagerInterface(this, parent); - connect(this, &Display::aboutToTerminate, m, [this,m] { delete m; }); + connect(this, &Display::aboutToTerminate, m, [m] { delete m; }); return m; } PlasmaShellInterface *Display::createPlasmaShell(QObject* parent) { auto s = new PlasmaShellInterface(this, parent); - connect(this, &Display::aboutToTerminate, s, [this, s] { delete s; }); + connect(this, &Display::aboutToTerminate, s, [s] { delete s; }); return s; } PlasmaWindowManagementInterface *Display::createPlasmaWindowManagement(QObject *parent) { auto wm = new PlasmaWindowManagementInterface(this, parent); - connect(this, &Display::aboutToTerminate, wm, [this, wm] { delete wm; }); + connect(this, &Display::aboutToTerminate, wm, [wm] { delete wm; }); return wm; } QtSurfaceExtensionInterface *Display::createQtSurfaceExtension(QObject *parent) { auto s = new QtSurfaceExtensionInterface(this, parent); - connect(this, &Display::aboutToTerminate, s, [this, s] { delete s; }); + connect(this, &Display::aboutToTerminate, s, [s] { delete s; }); return s; } RemoteAccessManagerInterface *Display::createRemoteAccessManager(QObject *parent) { auto i = new RemoteAccessManagerInterface(this, parent); - connect(this, &Display::aboutToTerminate, i, [this, i] { delete i; }); + connect(this, &Display::aboutToTerminate, i, [i] { delete i; }); return i; } IdleInterface *Display::createIdle(QObject *parent) { auto i = new IdleInterface(this, parent); - connect(this, &Display::aboutToTerminate, i, [this, i] { delete i; }); + connect(this, &Display::aboutToTerminate, i, [i] { delete i; }); return i; } FakeInputInterface *Display::createFakeInput(QObject *parent) { auto i = new FakeInputInterface(this, parent); - connect(this, &Display::aboutToTerminate, i, [this, i] { delete i; }); + connect(this, &Display::aboutToTerminate, i, [i] { delete i; }); return i; } ShadowManagerInterface *Display::createShadowManager(QObject *parent) { auto s = new ShadowManagerInterface(this, parent); - connect(this, &Display::aboutToTerminate, s, [this, s] { delete s; }); + connect(this, &Display::aboutToTerminate, s, [s] { delete s; }); return s; } BlurManagerInterface *Display::createBlurManager(QObject *parent) { auto b = new BlurManagerInterface(this, parent); - connect(this, &Display::aboutToTerminate, b, [this, b] { delete b; }); + connect(this, &Display::aboutToTerminate, b, [b] { delete b; }); return b; } ContrastManagerInterface *Display::createContrastManager(QObject *parent) { auto b = new ContrastManagerInterface(this, parent); - connect(this, &Display::aboutToTerminate, b, [this, b] { delete b; }); + connect(this, &Display::aboutToTerminate, b, [b] { delete b; }); return b; } SlideManagerInterface *Display::createSlideManager(QObject *parent) { auto b = new SlideManagerInterface(this, parent); - connect(this, &Display::aboutToTerminate, b, [this, b] { delete b; }); + connect(this, &Display::aboutToTerminate, b, [b] { delete b; }); return b; } DpmsManagerInterface *Display::createDpmsManager(QObject *parent) { auto d = new DpmsManagerInterface(this, parent); - connect(this, &Display::aboutToTerminate, d, [this, d] { delete d; }); + connect(this, &Display::aboutToTerminate, d, [d] { delete d; }); return d; } @@ -452,7 +452,7 @@ PointerConstraintsInterface *Display::createPointerConstraints(const PointerCons XdgForeignInterface *Display::createXdgForeignInterface(QObject *parent) { XdgForeignInterface *foreign = new XdgForeignInterface(this, parent); - connect(this, &Display::aboutToTerminate, foreign, [this,foreign] { delete foreign; }); + connect(this, &Display::aboutToTerminate, foreign, [foreign] { delete foreign; }); return foreign; } @@ -464,42 +464,42 @@ IdleInhibitManagerInterface *Display::createIdleInhibitManager(const IdleInhibit i = new IdleInhibitManagerUnstableV1Interface(this, parent); break; } - connect(this, &Display::aboutToTerminate, i, [this,i] { delete i; }); + connect(this, &Display::aboutToTerminate, i, [i] { delete i; }); return i; } AppMenuManagerInterface *Display::createAppMenuManagerInterface(QObject *parent) { auto b = new AppMenuManagerInterface(this, parent); - connect(this, &Display::aboutToTerminate, b, [this, b] { delete b; }); + connect(this, &Display::aboutToTerminate, b, [b] { delete b; }); return b; } ServerSideDecorationPaletteManagerInterface *Display::createServerSideDecorationPaletteManager(QObject *parent) { auto b = new ServerSideDecorationPaletteManagerInterface(this, parent); - connect(this, &Display::aboutToTerminate, b, [this, b] { delete b; }); + connect(this, &Display::aboutToTerminate, b, [b] { delete b; }); return b; } LinuxDmabufUnstableV1Interface *Display::createLinuxDmabufInterface(QObject *parent) { auto b = new LinuxDmabufUnstableV1Interface(this, parent); - connect(this, &Display::aboutToTerminate, b, [this, b] { delete b; }); + connect(this, &Display::aboutToTerminate, b, [b] { delete b; }); return b; } PlasmaVirtualDesktopManagementInterface *Display::createPlasmaVirtualDesktopManagement(QObject *parent) { auto b = new PlasmaVirtualDesktopManagementInterface(this, parent); - connect(this, &Display::aboutToTerminate, b, [this, b] { delete b; }); + connect(this, &Display::aboutToTerminate, b, [b] { delete b; }); return b; } XdgOutputManagerInterface *Display::createXdgOutputManager(QObject *parent) { auto b = new XdgOutputManagerInterface(this, parent); - connect(this, &Display::aboutToTerminate, b, [this, b] { delete b; }); + connect(this, &Display::aboutToTerminate, b, [b] { delete b; }); return b; } diff --git a/src/wayland/fakeinput_interface.cpp b/src/wayland/fakeinput_interface.cpp index b2d9e7eeaa..225aeef0dd 100644 --- a/src/wayland/fakeinput_interface.cpp +++ b/src/wayland/fakeinput_interface.cpp @@ -53,13 +53,10 @@ private: class FakeInputDevice::Private { public: - Private(wl_resource *resource, FakeInputInterface *interface, FakeInputDevice *q); + Private(wl_resource *resource, FakeInputInterface *interface); wl_resource *resource; FakeInputInterface *interface; bool authenticated = false; - -private: - FakeInputDevice *q; }; const quint32 FakeInputInterface::Private::s_version = 4; @@ -280,16 +277,15 @@ FakeInputInterface::FakeInputInterface(Display *display, QObject *parent) FakeInputInterface::~FakeInputInterface() = default; -FakeInputDevice::Private::Private(wl_resource *resource, FakeInputInterface *interface, FakeInputDevice *q) +FakeInputDevice::Private::Private(wl_resource *resource, FakeInputInterface *interface) : resource(resource) , interface(interface) - , q(q) { } FakeInputDevice::FakeInputDevice(wl_resource *resource, FakeInputInterface *parent) : QObject(parent) - , d(new Private(resource, parent, this)) + , d(new Private(resource, parent)) { } diff --git a/src/wayland/output_interface.cpp b/src/wayland/output_interface.cpp index ddfccd1c5a..21563175f0 100644 --- a/src/wayland/output_interface.cpp +++ b/src/wayland/output_interface.cpp @@ -114,7 +114,8 @@ OutputInterface::OutputInterface(Display *display, QObject *parent) { Q_D(); connect(this, &OutputInterface::currentModeChanged, this, - [this, d] { + [this] { + Q_D(); auto currentModeIt = std::find_if(d->modes.constBegin(), d->modes.constEnd(), [](const Mode &mode) { return mode.flags.testFlag(ModeFlag::Current); }); if (currentModeIt == d->modes.constEnd()) { return; @@ -126,12 +127,12 @@ OutputInterface::OutputInterface(Display *display, QObject *parent) wl_display_flush_clients(*(d->display)); } ); - connect(this, &OutputInterface::subPixelChanged, this, [this, d] { d->updateGeometry(); }); - connect(this, &OutputInterface::transformChanged, this, [this, d] { d->updateGeometry(); }); - connect(this, &OutputInterface::globalPositionChanged, this, [this, d] { d->updateGeometry(); }); - connect(this, &OutputInterface::modelChanged, this, [this, d] { d->updateGeometry(); }); - connect(this, &OutputInterface::manufacturerChanged, this, [this, d] { d->updateGeometry(); }); - connect(this, &OutputInterface::scaleChanged, this, [this, d] { d->updateScale(); }); + connect(this, &OutputInterface::subPixelChanged, this, [d] { d->updateGeometry(); }); + connect(this, &OutputInterface::transformChanged, this, [d] { d->updateGeometry(); }); + connect(this, &OutputInterface::globalPositionChanged, this, [d] { d->updateGeometry(); }); + connect(this, &OutputInterface::modelChanged, this, [d] { d->updateGeometry(); }); + connect(this, &OutputInterface::manufacturerChanged, this, [d] { d->updateGeometry(); }); + connect(this, &OutputInterface::scaleChanged, this, [d] { d->updateScale(); }); } OutputInterface::~OutputInterface() = default; diff --git a/src/wayland/plasmavirtualdesktop_interface.cpp b/src/wayland/plasmavirtualdesktop_interface.cpp index 88af8de65b..8b7f24bd73 100644 --- a/src/wayland/plasmavirtualdesktop_interface.cpp +++ b/src/wayland/plasmavirtualdesktop_interface.cpp @@ -42,7 +42,6 @@ private: return reinterpret_cast(wl_resource_get_user_data(resource)); } - wl_listener listener; static const struct org_kde_plasma_virtual_desktop_interface s_interface; }; diff --git a/src/wayland/plasmawindowmanagement_interface.cpp b/src/wayland/plasmawindowmanagement_interface.cpp index 7a1bc28c86..0dccda9773 100644 --- a/src/wayland/plasmawindowmanagement_interface.cpp +++ b/src/wayland/plasmawindowmanagement_interface.cpp @@ -110,7 +110,6 @@ private: QIcon m_icon; quint32 m_virtualDesktop = 0; quint32 m_state = 0; - wl_listener listener; static const struct org_kde_plasma_window_interface s_interface; }; diff --git a/src/wayland/server/buffer_interface.cpp b/src/wayland/server/buffer_interface.cpp index c21321c0cd..dc1b39686f 100644 --- a/src/wayland/server/buffer_interface.cpp +++ b/src/wayland/server/buffer_interface.cpp @@ -265,7 +265,7 @@ QImage::Format BufferInterface::Private::format() const QImage BufferInterface::data() { - return std::move(d->createImage()); + return d->createImage(); } QImage BufferInterface::Private::createImage() @@ -283,12 +283,12 @@ QImage BufferInterface::Private::createImage() s_accessedBuffer = this; s_accessCounter++; wl_shm_buffer_begin_access(shmBuffer); - return std::move(QImage((const uchar*)wl_shm_buffer_get_data(shmBuffer), - size.width(), - size.height(), - wl_shm_buffer_get_stride(shmBuffer), - imageFormat, - &imageBufferCleanupHandler, this)); + return QImage((const uchar*)wl_shm_buffer_get_data(shmBuffer), + size.width(), + size.height(), + wl_shm_buffer_get_stride(shmBuffer), + imageFormat, + &imageBufferCleanupHandler, this); } bool BufferInterface::isReferenced() const diff --git a/src/wayland/server/eglstream_controller_interface.cpp b/src/wayland/server/eglstream_controller_interface.cpp index 079f614672..d85f27d527 100644 --- a/src/wayland/server/eglstream_controller_interface.cpp +++ b/src/wayland/server/eglstream_controller_interface.cpp @@ -48,8 +48,8 @@ void EglStreamControllerInterface::Private::attachStreamConsumerAttribs(wl_clien EglStreamControllerInterface::Private::Private(EglStreamControllerInterface *q, Display *display) // libnvidia-egl-wayland.so.1 may not be present on all systems, so we load it dynamically : Global::Private(display, - (wl_interface *)QLibrary::resolve(QLatin1String("libnvidia-egl-wayland.so.1"), - "wl_eglstream_controller_interface"), + reinterpret_cast(QLibrary::resolve(QLatin1String("libnvidia-egl-wayland.so.1"), + "wl_eglstream_controller_interface")), s_version) , q(q) { diff --git a/src/wayland/server/textinput_interface_v0.cpp b/src/wayland/server/textinput_interface_v0.cpp index b1b8f0ddc5..113b6d13ef 100644 --- a/src/wayland/server/textinput_interface_v0.cpp +++ b/src/wayland/server/textinput_interface_v0.cpp @@ -376,7 +376,7 @@ void TextInputManagerUnstableV0Interface::Private::createTextInputCallback(wl_cl } ); QObject::connect(t, &TextInputUnstableV0Interface::requestActivate, m->q, - [t, m] (SeatInterface *seat) { + [t] (SeatInterface *seat) { // TODO: disallow for other seat seat->d_func()->registerTextInput(t); t->d_func()->seat = seat; diff --git a/src/wayland/tests/shadowtest.cpp b/src/wayland/tests/shadowtest.cpp index 54f6873e08..1e63542883 100644 --- a/src/wayland/tests/shadowtest.cpp +++ b/src/wayland/tests/shadowtest.cpp @@ -123,7 +123,7 @@ void ShadowTest::setupShadow() Shadow *shadow = m_shadowManager->createShadow(m_surface, this); Q_ASSERT(shadow); - auto addElement = [shadow, this](const QColor color) { + auto addElement = [this] (const QColor color) { const QSize size = QSize(10, 10); auto buffer = m_shm->getBuffer(size, size.width() * 4).toStrongRef(); buffer->setUsed(true); diff --git a/src/wayland/tests/touchclienttest.cpp b/src/wayland/tests/touchclienttest.cpp index df4fe2eac4..1bbdf97edc 100644 --- a/src/wayland/tests/touchclienttest.cpp +++ b/src/wayland/tests/touchclienttest.cpp @@ -128,7 +128,7 @@ void WaylandClientTest::setupRegistry(Registry *registry) } Keyboard *k = s->createKeyboard(this); connect(k, &Keyboard::keyChanged, this, - [this](quint32 key, Keyboard::KeyState state) { + [] (quint32 key, Keyboard::KeyState state) { if (key == KEY_Q && state == Keyboard::KeyState::Released) { QCoreApplication::instance()->quit(); } diff --git a/src/wayland/tests/xdgforeigntest.cpp b/src/wayland/tests/xdgforeigntest.cpp index 22a43094ee..9e083dc2b8 100644 --- a/src/wayland/tests/xdgforeigntest.cpp +++ b/src/wayland/tests/xdgforeigntest.cpp @@ -130,6 +130,7 @@ void XdgForeignTest::setupRegistry(Registry *registry) m_surface = m_compositor->createSurface(this); Q_ASSERT(m_surface); auto parentDeco = m_decoration->create(m_surface, this); + Q_UNUSED(parentDeco) m_shellSurface = m_shell->createSurface(m_surface, this); Q_ASSERT(m_shellSurface); connect(m_shellSurface, &XdgShellSurface::sizeChanged, this, &XdgForeignTest::render); @@ -137,6 +138,7 @@ void XdgForeignTest::setupRegistry(Registry *registry) m_childSurface = m_compositor->createSurface(this); Q_ASSERT(m_childSurface); auto childDeco = m_decoration->create(m_childSurface, this); + Q_UNUSED(childDeco) m_childShellSurface = m_shell->createSurface(m_childSurface, this); Q_ASSERT(m_childShellSurface); connect(m_childShellSurface, &XdgShellSurface::sizeChanged, this, &XdgForeignTest::render);