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;
private:
QWaylandDisplay *mDisplay;
QWaylandDisplay *mDisplay = nullptr;
QMimeData m_emptyData;
};

View File

@ -119,8 +119,8 @@ private:
struct wl_cursor* requestCursor(WaylandCursor shape);
void initCursorMap();
QWaylandDisplay *mDisplay;
struct wl_cursor_theme *mCursorTheme;
QWaylandDisplay *mDisplay = nullptr;
struct wl_cursor_theme *mCursorTheme = nullptr;
QPoint mLastPos;
QMap<WaylandCursor, wl_cursor *> mCursors;
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);
QMimeData *dragData;
QMimeData *dragData = nullptr;
Qt::DropActions supportedActions;
if (drag) {
dragData = drag->mimeData();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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