Use default member initialization for raw pointers

Initialize to nullptr to prevent undefined behavior.

Change-Id: I7753c0be77a886d62ecb1cd7b86fc8c98340b0b8
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Johan Klokkhammer Helsing 2018-02-27 16:21:17 +01:00 committed by Johan Helsing
parent 9147c0e688
commit 290e12e5a6
28 changed files with 57 additions and 57 deletions

View File

@ -78,7 +78,7 @@ public:
bool ownsMode(QClipboard::Mode mode) const override; bool ownsMode(QClipboard::Mode mode) const override;
private: private:
QWaylandDisplay *mDisplay; QWaylandDisplay *mDisplay = nullptr;
QMimeData m_emptyData; QMimeData m_emptyData;
}; };

View File

@ -119,8 +119,8 @@ private:
struct wl_cursor* requestCursor(WaylandCursor shape); struct wl_cursor* requestCursor(WaylandCursor shape);
void initCursorMap(); void initCursorMap();
QWaylandDisplay *mDisplay; QWaylandDisplay *mDisplay = nullptr;
struct wl_cursor_theme *mCursorTheme; struct wl_cursor_theme *mCursorTheme = nullptr;
QPoint mLastPos; QPoint mLastPos;
QMap<WaylandCursor, wl_cursor *> mCursors; QMap<WaylandCursor, wl_cursor *> mCursors;
QMultiMap<WaylandCursor, QByteArray> mCursorNamesMap; QMultiMap<WaylandCursor, QByteArray> mCursorNamesMap;

View File

@ -203,7 +203,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
m_dragPoint = calculateDragPosition(x, y, m_dragWindow); m_dragPoint = calculateDragPosition(x, y, m_dragWindow);
QMimeData *dragData; QMimeData *dragData = nullptr;
Qt::DropActions supportedActions; Qt::DropActions supportedActions;
if (drag) { if (drag) {
dragData = drag->mimeData(); dragData = drag->mimeData();

View File

@ -76,7 +76,7 @@ public:
QWaylandDisplay *display() const; QWaylandDisplay *display() const;
private: private:
QWaylandDisplay *m_display; QWaylandDisplay *m_display = nullptr;
}; };
} }

View File

@ -98,8 +98,8 @@ protected:
private: private:
int readData(int fd, QByteArray &data) const; int readData(int fd, QByteArray &data) const;
mutable QWaylandDataOffer *m_dataOffer; mutable QWaylandDataOffer *m_dataOffer = nullptr;
QWaylandDisplay *m_display; QWaylandDisplay *m_display = nullptr;
mutable QStringList m_types; mutable QStringList m_types;
mutable QHash<QString, QByteArray> m_data; mutable QHash<QString, QByteArray> m_data;
}; };

View File

@ -86,8 +86,8 @@ protected:
void data_source_target(const QString &mime_type) override; void data_source_target(const QString &mime_type) override;
private: private:
QWaylandDisplay *m_display; QWaylandDisplay *m_display = nullptr;
QMimeData *m_mime_data; QMimeData *m_mime_data = nullptr;
}; };
} }

View File

@ -149,7 +149,7 @@ public:
uint32_t id; uint32_t id;
QString interface; QString interface;
uint32_t version; uint32_t version;
struct ::wl_registry *registry; struct ::wl_registry *registry = nullptr;
RegistryGlobal(uint32_t id_, const QString &interface_, uint32_t version_, struct ::wl_registry *registry_) RegistryGlobal(uint32_t id_, const QString &interface_, uint32_t version_, struct ::wl_registry *registry_)
: id(id_), interface(interface_), version(version_), registry(registry_) { } : id(id_), interface(interface_), version(version_), registry(registry_) { }
}; };
@ -191,17 +191,17 @@ private:
void requestWaylandSync(); void requestWaylandSync();
struct Listener { struct Listener {
RegistryListener listener; RegistryListener listener = nullptr;
void *data; void *data = nullptr;
}; };
struct wl_display *mDisplay; struct wl_display *mDisplay = nullptr;
QtWayland::wl_compositor mCompositor; QtWayland::wl_compositor mCompositor;
QScopedPointer<QWaylandShm> mShm; QScopedPointer<QWaylandShm> mShm;
QList<QWaylandScreen *> mScreens; QList<QWaylandScreen *> mScreens;
QList<QWaylandInputDevice *> mInputDevices; QList<QWaylandInputDevice *> mInputDevices;
QList<Listener> mRegistryListeners; QList<Listener> mRegistryListeners;
QWaylandIntegration *mWaylandIntegration; QWaylandIntegration *mWaylandIntegration = nullptr;
#if QT_CONFIG(wayland_datadevice) #if QT_CONFIG(wayland_datadevice)
QScopedPointer<QWaylandDataDeviceManager> mDndSelectionHandler; QScopedPointer<QWaylandDataDeviceManager> mDndSelectionHandler;
#endif #endif
@ -212,7 +212,7 @@ private:
QScopedPointer<QWaylandWindowManagerIntegration> mWindowManagerIntegration; QScopedPointer<QWaylandWindowManagerIntegration> mWindowManagerIntegration;
QScopedPointer<QtWayland::zwp_text_input_manager_v2> mTextInputManager; QScopedPointer<QtWayland::zwp_text_input_manager_v2> mTextInputManager;
QScopedPointer<QWaylandHardwareIntegration> mHardwareIntegration; QScopedPointer<QWaylandHardwareIntegration> mHardwareIntegration;
QSocketNotifier *mReadNotifier; QSocketNotifier *mReadNotifier = nullptr;
int mFd; int mFd;
int mWritableNotificationFd; int mWritableNotificationFd;
QList<RegistryGlobal> mGlobals; QList<RegistryGlobal> mGlobals;

View File

@ -84,7 +84,7 @@ protected:
private: private:
QWaylandDisplay *m_display; QWaylandDisplay *m_display = nullptr;
}; };
#endif #endif
} }

View File

@ -83,7 +83,7 @@ private:
void extended_surface_set_generic_property(const QString &name, wl_array *value) override; void extended_surface_set_generic_property(const QString &name, wl_array *value) override;
void extended_surface_close() override; void extended_surface_close() override;
QWaylandWindow *m_window; QWaylandWindow *m_window = nullptr;
QVariantMap m_properties; QVariantMap m_properties;
}; };

View File

@ -107,7 +107,7 @@ protected:
private: private:
Qt::KeyboardModifiers modifiersToQtModifiers(uint32_t modifiers); Qt::KeyboardModifiers modifiersToQtModifiers(uint32_t modifiers);
QWaylandDisplay *m_display; QWaylandDisplay *m_display = nullptr;
QWaylandInputMethodEventBuilder m_builder; QWaylandInputMethodEventBuilder m_builder;
QVector<Qt::KeyboardModifier> m_modifiersMap; QVector<Qt::KeyboardModifier> m_modifiersMap;
@ -155,7 +155,7 @@ public:
private: private:
QWaylandTextInput *textInput() const; QWaylandTextInput *textInput() const;
QWaylandDisplay *mDisplay; QWaylandDisplay *mDisplay = nullptr;
QPointer<QWindow> mCurrentWindow; QPointer<QWindow> mCurrentWindow;
}; };

View File

@ -143,13 +143,13 @@ public:
private: private:
void setCursor(Qt::CursorShape cursor, QWaylandScreen *screen); void setCursor(Qt::CursorShape cursor, QWaylandScreen *screen);
QWaylandDisplay *mQDisplay; QWaylandDisplay *mQDisplay = nullptr;
struct wl_display *mDisplay; struct wl_display *mDisplay = nullptr;
int mVersion; int mVersion;
uint32_t mCaps = 0; uint32_t mCaps = 0;
struct wl_surface *pointerSurface; struct wl_surface *pointerSurface = nullptr;
#if QT_CONFIG(wayland_datadevice) #if QT_CONFIG(wayland_datadevice)
QWaylandDataDevice *mDataDevice = nullptr; QWaylandDataDevice *mDataDevice = nullptr;
@ -207,7 +207,7 @@ public:
uint32_t mods_locked, uint32_t mods_locked,
uint32_t group) override; uint32_t group) override;
QWaylandInputDevice *mParent; QWaylandInputDevice *mParent = nullptr;
QPointer<QWaylandWindow> mFocus; QPointer<QWaylandWindow> mFocus;
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon_evdev)
xkb_context *mXkbContext = nullptr; xkb_context *mXkbContext = nullptr;
@ -262,7 +262,7 @@ public:
void releaseButtons(); void releaseButtons();
QWaylandInputDevice *mParent; QWaylandInputDevice *mParent = nullptr;
QPointer<QWaylandWindow> mFocus; QPointer<QWaylandWindow> mFocus;
uint32_t mEnterSerial = 0; uint32_t mEnterSerial = 0;
#if QT_CONFIG(cursor) #if QT_CONFIG(cursor)
@ -302,7 +302,7 @@ public:
bool allTouchPointsReleased(); bool allTouchPointsReleased();
void releasePoints(); void releasePoints();
QWaylandInputDevice *mParent; QWaylandInputDevice *mParent = nullptr;
QPointer<QWaylandWindow> mFocus; QPointer<QWaylandWindow> mFocus;
QList<QWindowSystemInterface::TouchPoint> mTouchPoints; QList<QWindowSystemInterface::TouchPoint> mTouchPoints;
QList<QWindowSystemInterface::TouchPoint> mPrevTouchPoints; QList<QWindowSystemInterface::TouchPoint> mPrevTouchPoints;

View File

@ -85,7 +85,7 @@ public:
QFunctionPointer platformFunction(const QByteArray &resource) const override; QFunctionPointer platformFunction(const QByteArray &resource) const override;
private: private:
QWaylandIntegration *m_integration; QWaylandIntegration *m_integration = nullptr;
QHash<QPlatformWindow*, QVariantMap> m_windowProperties; QHash<QPlatformWindow*, QVariantMap> m_windowProperties;
static void setSync(QWindow *window); static void setSync(QWindow *window);

View File

@ -68,7 +68,7 @@ public:
QWaylandQtKeyExtension(QWaylandDisplay *display, uint32_t id); QWaylandQtKeyExtension(QWaylandDisplay *display, uint32_t id);
private: private:
QWaylandDisplay *m_display; QWaylandDisplay *m_display = nullptr;
void key_extension_qtkey(struct wl_surface *surface, void key_extension_qtkey(struct wl_surface *surface,
uint32_t time, uint32_t time,

View File

@ -104,7 +104,7 @@ protected:
virtual void setMinimized() {} virtual void setMinimized() {}
private: private:
QWaylandWindow *m_window; QWaylandWindow *m_window = nullptr;
friend class QWaylandWindow; friend class QWaylandWindow;
}; };

View File

@ -86,8 +86,8 @@ private:
// to keep track of the sync state // to keep track of the sync state
void set_sync(); void set_sync();
void set_desync(); void set_desync();
QWaylandWindow *m_window; QWaylandWindow *m_window = nullptr;
QWaylandWindow *m_parent; QWaylandWindow *m_parent = nullptr;
bool m_synchronized = false; bool m_synchronized = false;
QMutex m_syncLock; QMutex m_syncLock;

View File

@ -73,7 +73,7 @@ public:
private: private:
void registerDevice(int caps); void registerDevice(int caps);
QWaylandDisplay *mDisplay; QWaylandDisplay *mDisplay = nullptr;
void touch_extension_touch(uint32_t time, void touch_extension_touch(uint32_t time,
uint32_t id, uint32_t id,
@ -95,15 +95,15 @@ private:
QList<QWindowSystemInterface::TouchPoint> mTouchPoints; QList<QWindowSystemInterface::TouchPoint> mTouchPoints;
QList<QWindowSystemInterface::TouchPoint> mPrevTouchPoints; QList<QWindowSystemInterface::TouchPoint> mPrevTouchPoints;
QTouchDevice *mTouchDevice; QTouchDevice *mTouchDevice = nullptr;
uint32_t mTimestamp; uint32_t mTimestamp;
int mPointsLeft; int mPointsLeft;
uint32_t mFlags; uint32_t mFlags;
int mMouseSourceId; int mMouseSourceId;
QPointF mLastMouseLocal; QPointF mLastMouseLocal;
QPointF mLastMouseGlobal; QPointF mLastMouseGlobal;
QWindow *mTargetWindow; QWindow *mTargetWindow = nullptr;
QWaylandInputDevice *mInputDevice; QWaylandInputDevice *mInputDevice = nullptr;
}; };
} }

View File

@ -61,7 +61,7 @@ class QWaylandWindowManagerIntegrationPrivate {
public: public:
QWaylandWindowManagerIntegrationPrivate(QWaylandDisplay *waylandDisplay); QWaylandWindowManagerIntegrationPrivate(QWaylandDisplay *waylandDisplay);
bool m_blockPropertyUpdates = false; bool m_blockPropertyUpdates = false;
QWaylandDisplay *m_waylandDisplay; QWaylandDisplay *m_waylandDisplay = nullptr;
QHash<QWindow*, QVariantMap> m_queuedProperties; QHash<QWindow*, QVariantMap> m_queuedProperties;
bool m_showIsFullScreen = false; bool m_showIsFullScreen = false;
}; };

View File

@ -104,7 +104,7 @@ private:
void updateTransientParent(QWindow *parent); void updateTransientParent(QWindow *parent);
void setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, uint serial); void setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, uint serial);
QWaylandWindow *m_window; QWaylandWindow *m_window = nullptr;
bool m_maximized = false; bool m_maximized = false;
bool m_fullscreen = false; bool m_fullscreen = false;
QSize m_size; QSize m_size;

View File

@ -81,7 +81,7 @@ protected:
private: private:
QWaylandExtendedSurface *m_extendedWindow = nullptr; QWaylandExtendedSurface *m_extendedWindow = nullptr;
QWaylandWindow *m_window; QWaylandWindow *m_window = nullptr;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -106,7 +106,7 @@ private:
QVarLengthArray<uint32_t> states; QVarLengthArray<uint32_t> states;
} m_configureState; } m_configureState;
QWaylandXdgSurfaceV6 *m_xdgSurface; QWaylandXdgSurfaceV6 *m_xdgSurface = nullptr;
}; };
class Popup : public QtWayland::zxdg_popup_v6 { class Popup : public QtWayland::zxdg_popup_v6 {
@ -117,14 +117,14 @@ private:
void applyConfigure(); void applyConfigure();
void zxdg_popup_v6_popup_done() override; void zxdg_popup_v6_popup_done() override;
QWaylandXdgSurfaceV6 *m_xdgSurface; QWaylandXdgSurfaceV6 *m_xdgSurface = nullptr;
}; };
void setToplevel(); void setToplevel();
void setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, int serial, bool grab); void setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, int serial, bool grab);
QWaylandXdgShellV6 *m_shell; QWaylandXdgShellV6 *m_shell = nullptr;
QWaylandWindow *m_window; QWaylandWindow *m_window = nullptr;
Toplevel *m_toplevel = nullptr; Toplevel *m_toplevel = nullptr;
Popup *m_popup = nullptr; Popup *m_popup = nullptr;
bool m_configured = false; bool m_configured = false;

View File

@ -110,8 +110,8 @@ private:
void updateTransientParent(QWaylandWindow *parent); void updateTransientParent(QWaylandWindow *parent);
private: private:
QWaylandWindow *m_window; QWaylandWindow *m_window = nullptr;
QWaylandXdgShell* m_shell; QWaylandXdgShell* m_shell = nullptr;
bool m_maximized = false; bool m_maximized = false;
bool m_minimized = false; bool m_minimized = false;
bool m_fullscreen = false; bool m_fullscreen = false;

View File

@ -63,7 +63,7 @@ private:
, data(data) , data(data)
{ } { }
const size_t size; const size_t size;
const wl_shm_format *data; const wl_shm_format *data = nullptr;
}; };
static const Array getData() static const Array getData()

View File

@ -81,7 +81,7 @@ public:
} }
protected: protected:
QWaylandDisplay *m_display; QWaylandDisplay *m_display = nullptr;
}; };
} }

View File

@ -170,7 +170,7 @@ private slots:
void glWindow(); void glWindow();
private: private:
MockCompositor *compositor; MockCompositor *compositor = nullptr;
}; };
void tst_WaylandClient::primaryScreen() void tst_WaylandClient::primaryScreen()

View File

@ -141,7 +141,7 @@ private:
friend class Impl::Compositor; friend class Impl::Compositor;
friend class Impl::Surface; friend class Impl::Surface;
Impl::Surface *m_surface; Impl::Surface *m_surface = nullptr;
}; };
Q_DECLARE_METATYPE(QSharedPointer<MockSurface>) Q_DECLARE_METATYPE(QSharedPointer<MockSurface>)
@ -151,7 +151,7 @@ public:
Impl::Output *handle() const { return m_output; } Impl::Output *handle() const { return m_output; }
MockOutput(Impl::Output *output); MockOutput(Impl::Output *output);
private: private:
Impl::Output *m_output; Impl::Output *m_output = nullptr;
}; };
Q_DECLARE_METATYPE(QSharedPointer<MockOutput>) Q_DECLARE_METATYPE(QSharedPointer<MockOutput>)
@ -201,7 +201,7 @@ private:
typedef void (*Callback)(void *target, const QList<QVariant> &parameters); typedef void (*Callback)(void *target, const QList<QVariant> &parameters);
Callback callback; Callback callback;
void *target; void *target = nullptr;
QList<QVariant> parameters; QList<QVariant> parameters;
}; };

View File

@ -60,7 +60,7 @@ protected:
void seat_get_touch(Resource *resource, uint32_t id) override; void seat_get_touch(Resource *resource, uint32_t id) override;
private: private:
Compositor *m_compositor; Compositor *m_compositor = nullptr;
QScopedPointer<Keyboard> m_keyboard; QScopedPointer<Keyboard> m_keyboard;
QScopedPointer<Pointer> m_pointer; QScopedPointer<Pointer> m_pointer;
@ -83,7 +83,7 @@ protected:
void keyboard_destroy_resource(wl_keyboard::Resource *resource) override; void keyboard_destroy_resource(wl_keyboard::Resource *resource) override;
private: private:
Compositor *m_compositor; Compositor *m_compositor = nullptr;
Resource *m_focusResource = nullptr; Resource *m_focusResource = nullptr;
Surface *m_focus = nullptr; Surface *m_focus = nullptr;
@ -106,7 +106,7 @@ protected:
void pointer_destroy_resource(wl_pointer::Resource *resource) override; void pointer_destroy_resource(wl_pointer::Resource *resource) override;
private: private:
Compositor *m_compositor; Compositor *m_compositor = nullptr;
Resource *m_focusResource = nullptr; Resource *m_focusResource = nullptr;
Surface *m_focus = nullptr; Surface *m_focus = nullptr;
@ -121,7 +121,7 @@ public:
void sendMotion(Surface *surface, const QPoint &position, int id); void sendMotion(Surface *surface, const QPoint &position, int id);
void sendFrame(Surface *surface); void sendFrame(Surface *surface);
private: private:
Compositor *m_compositor; Compositor *m_compositor = nullptr;
}; };
class DataOffer : public QtWaylandServer::wl_data_offer class DataOffer : public QtWaylandServer::wl_data_offer
@ -145,7 +145,7 @@ protected:
void data_device_start_drag(Resource *resource, struct ::wl_resource *source, struct ::wl_resource *origin, struct ::wl_resource *icon, uint32_t serial) override; void data_device_start_drag(Resource *resource, struct ::wl_resource *source, struct ::wl_resource *origin, struct ::wl_resource *icon, uint32_t serial) override;
private: private:
Compositor *m_compositor; Compositor *m_compositor = nullptr;
QtWaylandServer::wl_data_offer *m_dataOffer = nullptr; QtWaylandServer::wl_data_offer *m_dataOffer = nullptr;
Surface* m_focus = nullptr; Surface* m_focus = nullptr;
}; };
@ -162,7 +162,7 @@ protected:
void data_device_manager_create_data_source(Resource *resource, uint32_t id) override; void data_device_manager_create_data_source(Resource *resource, uint32_t id) override;
private: private:
Compositor *m_compositor; Compositor *m_compositor = nullptr;
QScopedPointer<DataDevice> m_data_device; QScopedPointer<DataDevice> m_data_device;
}; };

View File

@ -65,7 +65,7 @@ protected:
private: private:
wl_resource *m_buffer = nullptr; wl_resource *m_buffer = nullptr;
Compositor *m_compositor; Compositor *m_compositor = nullptr;
QSharedPointer<MockSurface> m_mockSurface; QSharedPointer<MockSurface> m_mockSurface;
QList<wl_resource *> m_frameCallbackList; QList<wl_resource *> m_frameCallbackList;
bool m_mapped = false; bool m_mapped = false;

View File

@ -82,7 +82,7 @@ private slots:
void createDestroyWindow(); void createDestroyWindow();
private: private:
MockCompositor *m_compositor; MockCompositor *m_compositor = nullptr;
}; };
void tst_WaylandClientXdgShellV6::createDestroyWindow() void tst_WaylandClientXdgShellV6::createDestroyWindow()