From c4bd9198b4a0fac809903dd2c09276c2c3c1b22e Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 27 Feb 2018 11:32:15 +0100 Subject: Init variables where they are declared when possible (clang-tidy) clang-tidy -p compile_commands.json $file \ -checks='-*,modernize-use-default-member-init,readability-redundant-member-init' \ -config='{CheckOptions: [{key: modernize-use-default-member-init.UseAssignment, value: "1"}]}' \ -header-filter='qtwayland' \ -fix Afterwards I ran search and replace on the diff to clean up some whitespace errors: - Replaced '(\n\+[^:\n]*)(:\s+\+\s+)' with '$1: ' - Replaced '(\n\+[^,\n]*)(,\s+\+\s+)' with '$1, ' - Replaced '\n\+\s*\n' with '\n' I also had to do some manual edits, because for some reason, this particular clang-tidy check doesn't trigger for some files. Change-Id: I3b3909bac4bf20108bbe8ad1e01bcc54236dae1b Reviewed-by: Shawn Rutledge --- .../custom-extension/client-common/customextension.cpp | 1 - .../custom-extension/client-common/customextension.h | 2 +- examples/wayland/minimal-cpp/compositor.cpp | 3 +-- examples/wayland/minimal-cpp/compositor.h | 4 ++-- examples/wayland/minimal-cpp/window.cpp | 1 - examples/wayland/minimal-cpp/window.h | 2 +- examples/wayland/qwindow-compositor/compositor.cpp | 10 +--------- examples/wayland/qwindow-compositor/compositor.h | 16 ++++++++-------- examples/wayland/qwindow-compositor/window.cpp | 4 ---- examples/wayland/qwindow-compositor/window.h | 8 ++++---- .../server-buffer/compositor/sharebufferextension.cpp | 2 -- .../server-buffer/compositor/sharebufferextension.h | 4 ++-- examples/wayland/server-buffer/cpp-client/main.cpp | 3 +-- 13 files changed, 21 insertions(+), 39 deletions(-) (limited to 'examples/wayland') diff --git a/examples/wayland/custom-extension/client-common/customextension.cpp b/examples/wayland/custom-extension/client-common/customextension.cpp index 41b4a30e9..90e1f4377 100644 --- a/examples/wayland/custom-extension/client-common/customextension.cpp +++ b/examples/wayland/custom-extension/client-common/customextension.cpp @@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE CustomExtension::CustomExtension() : QWaylandClientExtensionTemplate(/* Supported protocol version */ 1 ) - , m_activated(false) { connect(this, &CustomExtension::activeChanged, this, &CustomExtension::handleExtensionActive); } diff --git a/examples/wayland/custom-extension/client-common/customextension.h b/examples/wayland/custom-extension/client-common/customextension.h index 003a5a008..5e48ea75e 100644 --- a/examples/wayland/custom-extension/client-common/customextension.h +++ b/examples/wayland/custom-extension/client-common/customextension.h @@ -93,7 +93,7 @@ private: void sendWindowRegistration(QWindow *); QList m_windows; - bool m_activated; + bool m_activated = false; }; class CustomExtensionObject : public QWaylandClientExtensionTemplate diff --git a/examples/wayland/minimal-cpp/compositor.cpp b/examples/wayland/minimal-cpp/compositor.cpp index 52c2c2326..d32d8e888 100644 --- a/examples/wayland/minimal-cpp/compositor.cpp +++ b/examples/wayland/minimal-cpp/compositor.cpp @@ -66,8 +66,7 @@ bool View::isCursor() const } Compositor::Compositor(Window *window) - : QWaylandCompositor() - , m_window(window) + : m_window(window) { } diff --git a/examples/wayland/minimal-cpp/compositor.h b/examples/wayland/minimal-cpp/compositor.h index 76af25ecb..9dd5cb2f0 100644 --- a/examples/wayland/minimal-cpp/compositor.h +++ b/examples/wayland/minimal-cpp/compositor.h @@ -64,12 +64,12 @@ class View : public QWaylandView { Q_OBJECT public: - View() : m_texture(nullptr) {} + View() {} QOpenGLTexture *getTexture(); bool isCursor() const; private: friend class Compositor; - QOpenGLTexture *m_texture; + QOpenGLTexture *m_texture = nullptr; }; class Compositor : public QWaylandCompositor diff --git a/examples/wayland/minimal-cpp/window.cpp b/examples/wayland/minimal-cpp/window.cpp index 9de81e5f4..b84806472 100644 --- a/examples/wayland/minimal-cpp/window.cpp +++ b/examples/wayland/minimal-cpp/window.cpp @@ -58,7 +58,6 @@ #include Window::Window() - : m_compositor(nullptr) { } diff --git a/examples/wayland/minimal-cpp/window.h b/examples/wayland/minimal-cpp/window.h index 5396da15c..2a7a1109a 100644 --- a/examples/wayland/minimal-cpp/window.h +++ b/examples/wayland/minimal-cpp/window.h @@ -70,7 +70,7 @@ protected: private: QOpenGLTextureBlitter m_textureBlitter; - Compositor *m_compositor; + Compositor *m_compositor = nullptr; }; QT_END_NAMESPACE diff --git a/examples/wayland/qwindow-compositor/compositor.cpp b/examples/wayland/qwindow-compositor/compositor.cpp index 11516a182..8ba8929e1 100644 --- a/examples/wayland/qwindow-compositor/compositor.cpp +++ b/examples/wayland/qwindow-compositor/compositor.cpp @@ -68,13 +68,6 @@ View::View(Compositor *compositor) : m_compositor(compositor) - , m_textureTarget(GL_TEXTURE_2D) - , m_texture(nullptr) - , m_wlShellSurface(nullptr) - , m_xdgSurface(nullptr) - , m_xdgPopup(nullptr) - , m_parentView(nullptr) - , m_animationFactor(1.0) {} QOpenGLTexture *View::getTexture() @@ -190,8 +183,7 @@ void View::onXdgUnsetFullscreen() } Compositor::Compositor(QWindow *window) - : QWaylandCompositor() - , m_window(window) + : m_window(window) , m_wlShell(new QWaylandWlShell(this)) , m_xdgShell(new QWaylandXdgShellV5(this)) { diff --git a/examples/wayland/qwindow-compositor/compositor.h b/examples/wayland/qwindow-compositor/compositor.h index b0fc0c84e..d1b501ff8 100644 --- a/examples/wayland/qwindow-compositor/compositor.h +++ b/examples/wayland/qwindow-compositor/compositor.h @@ -96,18 +96,18 @@ protected: private: friend class Compositor; - Compositor *m_compositor; - GLenum m_textureTarget; - QOpenGLTexture *m_texture; + Compositor *m_compositor = nullptr; + GLenum m_textureTarget = GL_TEXTURE_2D; + QOpenGLTexture *m_texture = nullptr; QOpenGLTextureBlitter::Origin m_origin; QPointF m_position; QSize m_size; - QWaylandWlShellSurface *m_wlShellSurface; - QWaylandXdgSurfaceV5 *m_xdgSurface; - QWaylandXdgPopupV5 *m_xdgPopup; - View *m_parentView; + QWaylandWlShellSurface *m_wlShellSurface = nullptr; + QWaylandXdgSurfaceV5 *m_xdgSurface = nullptr; + QWaylandXdgPopupV5 *m_xdgPopup = nullptr; + View *m_parentView = nullptr; QPoint m_offset; - qreal m_animationFactor; + qreal m_animationFactor = 1.0; QBasicTimer m_animationTimer; bool m_animationCountUp; diff --git a/examples/wayland/qwindow-compositor/window.cpp b/examples/wayland/qwindow-compositor/window.cpp index 9d5b4395e..80aeec4c3 100644 --- a/examples/wayland/qwindow-compositor/window.cpp +++ b/examples/wayland/qwindow-compositor/window.cpp @@ -60,10 +60,6 @@ #include Window::Window() - : m_backgroundTexture(nullptr) - , m_compositor(nullptr) - , m_grabState(NoGrab) - , m_dragIconView(nullptr) { } diff --git a/examples/wayland/qwindow-compositor/window.h b/examples/wayland/qwindow-compositor/window.h index d11553151..c16e726bf 100644 --- a/examples/wayland/qwindow-compositor/window.h +++ b/examples/wayland/qwindow-compositor/window.h @@ -96,17 +96,17 @@ private: QOpenGLTextureBlitter m_textureBlitter; QSize m_backgroundImageSize; - QOpenGLTexture *m_backgroundTexture; - Compositor *m_compositor; + QOpenGLTexture *m_backgroundTexture = nullptr; + Compositor *m_compositor = nullptr; QPointer m_mouseView; - GrabState m_grabState; + GrabState m_grabState = NoGrab; QSize m_initialSize; int m_resizeEdge; bool m_resizeAnchored; QPointF m_resizeAnchorPosition; QPointF m_mouseOffset; QPointF m_initialMousePos; - View *m_dragIconView; + View *m_dragIconView = nullptr; }; QT_END_NAMESPACE diff --git a/examples/wayland/server-buffer/compositor/sharebufferextension.cpp b/examples/wayland/server-buffer/compositor/sharebufferextension.cpp index 8277dad34..71731ed22 100644 --- a/examples/wayland/server-buffer/compositor/sharebufferextension.cpp +++ b/examples/wayland/server-buffer/compositor/sharebufferextension.cpp @@ -61,8 +61,6 @@ ShareBufferExtension::ShareBufferExtension(QWaylandCompositor *compositor) : QWaylandCompositorExtensionTemplate(compositor) - , m_server_buffer_integration(nullptr) - , m_server_buffers_created(false) { } diff --git a/examples/wayland/server-buffer/compositor/sharebufferextension.h b/examples/wayland/server-buffer/compositor/sharebufferextension.h index f84d9c4df..4719844b3 100644 --- a/examples/wayland/server-buffer/compositor/sharebufferextension.h +++ b/examples/wayland/server-buffer/compositor/sharebufferextension.h @@ -89,8 +89,8 @@ protected: private: void createServerBuffers(); QList m_server_buffers; - QtWayland::ServerBufferIntegration *m_server_buffer_integration; - bool m_server_buffers_created; + QtWayland::ServerBufferIntegration *m_server_buffer_integration = nullptr; + bool m_server_buffers_created = false; }; Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(ShareBufferExtension) diff --git a/examples/wayland/server-buffer/cpp-client/main.cpp b/examples/wayland/server-buffer/cpp-client/main.cpp index b0b3712b9..7ff34072b 100644 --- a/examples/wayland/server-buffer/cpp-client/main.cpp +++ b/examples/wayland/server-buffer/cpp-client/main.cpp @@ -73,7 +73,6 @@ class TestWindow : public QOpenGLWindow public: TestWindow() - : m_extension(nullptr) { m_extension = new ShareBufferExtension; connect(m_extension, SIGNAL(bufferReceived(QtWaylandClient::QWaylandServerBuffer*)), this, SLOT(receiveBuffer(QtWaylandClient::QWaylandServerBuffer*))); @@ -118,7 +117,7 @@ protected: private: QOpenGLTextureBlitter *m_blitter; - ShareBufferExtension *m_extension; + ShareBufferExtension *m_extension = nullptr; QList m_buffers; }; -- cgit v1.2.3