aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2018-02-21 11:52:59 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2018-02-26 13:08:30 +0000
commit06e962f263a86c4b66e1c6195b3d2615695fea1e (patch)
tree3669793f9983762538a9cb12a07ce49d461f066d /src/quick/items
parent78e875e6dbd4991fe22c194d8608b3d66c96e036 (diff)
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='qtdeclarative' -fix Change-Id: I705f3235ff129ba68b0d8dad54a083e29fcead5f Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/qquickanchors_p_p.h6
-rw-r--r--src/quick/items/qquickevents_p_p.h41
-rw-r--r--src/quick/items/qquickitem_p.h23
-rw-r--r--src/quick/items/qquickmultipointtoucharea_p.h41
-rw-r--r--src/quick/items/qquickspriteengine_p.h9
5 files changed, 50 insertions, 70 deletions
diff --git a/src/quick/items/qquickanchors_p_p.h b/src/quick/items/qquickanchors_p_p.h
index db929f99f3..0a834276ae 100644
--- a/src/quick/items/qquickanchors_p_p.h
+++ b/src/quick/items/qquickanchors_p_p.h
@@ -60,15 +60,15 @@ QT_BEGIN_NAMESPACE
class QQuickAnchorLine
{
public:
- QQuickAnchorLine() : item(nullptr), anchorLine(QQuickAnchors::InvalidAnchor) {}
+ QQuickAnchorLine() {}
QQuickAnchorLine(QQuickItem *i, QQuickAnchors::Anchor l) : item(i), anchorLine(l) {}
QQuickAnchorLine(QQuickItem *i, uint l)
: item(i)
, anchorLine(static_cast<QQuickAnchors::Anchor>(l))
{ Q_ASSERT(l < ((QQuickAnchors::BaselineAnchor << 1) - 1)); }
- QQuickItem *item;
- QQuickAnchors::Anchor anchorLine;
+ QQuickItem *item = nullptr;
+ QQuickAnchors::Anchor anchorLine = QQuickAnchors::InvalidAnchor;
};
inline bool operator==(const QQuickAnchorLine& a, const QQuickAnchorLine& b)
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h
index d6aca87f84..e430832fe7 100644
--- a/src/quick/items/qquickevents_p_p.h
+++ b/src/quick/items/qquickevents_p_p.h
@@ -135,8 +135,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickMouseEvent : public QObject
public:
QQuickMouseEvent()
- : _x(0), _y(0), _button(Qt::NoButton), _buttons(Qt::NoButton), _modifiers(Qt::NoModifier)
- , _source(Qt::MouseEventNotSynthesized), _wasHeld(false), _isClick(false), _accepted(false)
+ : _buttons(Qt::NoButton), _modifiers(Qt::NoModifier)
+ , _wasHeld(false), _isClick(false), _accepted(false)
, _flags(Qt::MouseEventFlags(nullptr))
{}
@@ -175,12 +175,12 @@ public:
void setAccepted(bool accepted) { _accepted = accepted; }
int flags() const { return _flags; }
private:
- qreal _x;
- qreal _y;
- Qt::MouseButton _button;
+ qreal _x = 0;
+ qreal _y = 0;
+ Qt::MouseButton _button = Qt::NoButton;
Qt::MouseButtons _buttons;
Qt::KeyboardModifiers _modifiers;
- Qt::MouseEventSource _source;
+ Qt::MouseEventSource _source = Qt::MouseEventNotSynthesized;
bool _wasHeld : 1;
bool _isClick : 1;
bool _accepted : 1;
@@ -201,8 +201,7 @@ class QQuickWheelEvent : public QObject
public:
QQuickWheelEvent()
- : _x(0), _y(0), _buttons(Qt::NoButton), _modifiers(Qt::NoModifier)
- , _inverted(false), _accepted(false)
+ : _buttons(Qt::NoButton), _modifiers(Qt::NoModifier)
{}
void reset(qreal x, qreal y, const QPoint &angleDelta, const QPoint &pixelDelta,
@@ -229,14 +228,14 @@ public:
void setAccepted(bool accepted) { _accepted = accepted; }
private:
- qreal _x;
- qreal _y;
+ qreal _x = 0;
+ qreal _y = 0;
QPoint _angleDelta;
QPoint _pixelDelta;
Qt::MouseButtons _buttons;
Qt::KeyboardModifiers _modifiers;
- bool _inverted;
- bool _accepted;
+ bool _inverted = false;
+ bool _accepted = false;
};
class Q_QUICK_PRIVATE_EXPORT QQuickCloseEvent : public QObject
@@ -245,14 +244,13 @@ class Q_QUICK_PRIVATE_EXPORT QQuickCloseEvent : public QObject
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
public:
- QQuickCloseEvent()
- : _accepted(true) {}
+ QQuickCloseEvent() {}
bool isAccepted() { return _accepted; }
void setAccepted(bool accepted) { _accepted = accepted; }
private:
- bool _accepted;
+ bool _accepted = true;
};
class Q_QUICK_PRIVATE_EXPORT QQuickEventPoint : public QObject
@@ -394,10 +392,8 @@ public:
QQuickPointerEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
: QObject(parent)
, m_device(device)
- , m_event(nullptr)
- , m_button(Qt::NoButton)
, m_pressedButtons(Qt::NoButton)
- { }
+ {}
virtual ~QQuickPointerEvent();
@@ -441,8 +437,8 @@ public: // helpers for C++ only (during event delivery)
protected:
QQuickPointerDevice *m_device;
- QInputEvent *m_event; // original event as received by QQuickWindow
- Qt::MouseButton m_button;
+ QInputEvent *m_event = nullptr; // original event as received by QQuickWindow
+ Qt::MouseButton m_button = Qt::NoButton;
Qt::MouseButtons m_pressedButtons;
Q_DISABLE_COPY(QQuickPointerEvent)
@@ -487,9 +483,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerTouchEvent : public QQuickPointerEvent
public:
QQuickPointerTouchEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
: QQuickPointerEvent(parent, device)
- , m_pointCount(0)
, m_synthMouseEvent(QEvent::MouseMove, QPointF(), Qt::NoButton, Qt::NoButton, Qt::NoModifier)
- { }
+ {}
QQuickPointerEvent *reset(QEvent *) override;
void localize(QQuickItem *target) override;
@@ -515,7 +510,7 @@ public:
QTouchEvent *asTouchEvent() const;
private:
- int m_pointCount;
+ int m_pointCount = 0;
QVector<QQuickEventTouchPoint *> m_touchPoints;
mutable QMouseEvent m_synthMouseEvent;
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h
index 2e91e2111c..1a3be437af 100644
--- a/src/quick/items/qquickitem_p.h
+++ b/src/quick/items/qquickitem_p.h
@@ -661,17 +661,15 @@ class QQuickKeyNavigationAttachedPrivate : public QObjectPrivate
{
public:
QQuickKeyNavigationAttachedPrivate()
- : QObjectPrivate(),
- left(nullptr), right(nullptr), up(nullptr), down(nullptr), tab(nullptr), backtab(nullptr),
- leftSet(false), rightSet(false), upSet(false), downSet(false),
+ : leftSet(false), rightSet(false), upSet(false), downSet(false),
tabSet(false), backtabSet(false) {}
- QQuickItem *left;
- QQuickItem *right;
- QQuickItem *up;
- QQuickItem *down;
- QQuickItem *tab;
- QQuickItem *backtab;
+ QQuickItem *left = nullptr;
+ QQuickItem *right = nullptr;
+ QQuickItem *up = nullptr;
+ QQuickItem *down = nullptr;
+ QQuickItem *tab = nullptr;
+ QQuickItem *backtab = nullptr;
bool leftSet : 1;
bool rightSet : 1;
bool upSet : 1;
@@ -782,8 +780,7 @@ class QQuickKeysAttachedPrivate : public QObjectPrivate
{
public:
QQuickKeysAttachedPrivate()
- : QObjectPrivate(), inPress(false), inRelease(false)
- , inIM(false), enabled(true), imeItem(nullptr), item(nullptr)
+ : inPress(false), inRelease(false), inIM(false), enabled(true)
{}
//loop detection
@@ -793,9 +790,9 @@ public:
bool enabled : 1;
- QQuickItem *imeItem;
+ QQuickItem *imeItem = nullptr;
QList<QQuickItem *> targets;
- QQuickItem *item;
+ QQuickItem *item = nullptr;
QQuickKeyEvent theKeyEvent;
};
diff --git a/src/quick/items/qquickmultipointtoucharea_p.h b/src/quick/items/qquickmultipointtoucharea_p.h
index a6acdfc97d..f1550b4ac6 100644
--- a/src/quick/items/qquickmultipointtoucharea_p.h
+++ b/src/quick/items/qquickmultipointtoucharea_p.h
@@ -86,16 +86,7 @@ class Q_AUTOTEST_EXPORT QQuickTouchPoint : public QObject
public:
QQuickTouchPoint(bool qmlDefined = true)
- : _id(0),
- _x(0.0), _y(0.0),
- _pressure(0.0),
- _rotation(0),
- _qmlDefined(qmlDefined),
- _inUse(false),
- _pressed(false),
- _startX(0.0), _startY(0.0),
- _previousX(0.0), _previousY(0.0),
- _sceneX(0.0), _sceneY(0.0)
+ : _qmlDefined(qmlDefined)
{}
int pointId() const { return _id; }
@@ -171,23 +162,23 @@ Q_SIGNALS:
private:
friend class QQuickMultiPointTouchArea;
- int _id;
- qreal _x;
- qreal _y;
- qreal _pressure;
- qreal _rotation;
+ int _id = 0;
+ qreal _x = 0.0;
+ qreal _y = 0.0;
+ qreal _pressure = 0.0;
+ qreal _rotation = 0;
QSizeF _ellipseDiameters;
QVector2D _velocity;
QRectF _area;
bool _qmlDefined;
- bool _inUse; //whether the point is currently in use (only valid when _qmlDefined == true)
- bool _pressed;
- qreal _startX;
- qreal _startY;
- qreal _previousX;
- qreal _previousY;
- qreal _sceneX;
- qreal _sceneY;
+ bool _inUse = false; //whether the point is currently in use (only valid when _qmlDefined == true)
+ bool _pressed = false;
+ qreal _startX = 0.0;
+ qreal _startY = 0.0;
+ qreal _previousX = 0.0;
+ qreal _previousY = 0.0;
+ qreal _sceneX = 0.0;
+ qreal _sceneY = 0.0;
QPointingDeviceUniqueId _uniqueId;
};
@@ -197,7 +188,7 @@ class QQuickGrabGestureEvent : public QObject
Q_PROPERTY(QQmlListProperty<QObject> touchPoints READ touchPoints)
Q_PROPERTY(qreal dragThreshold READ dragThreshold)
public:
- QQuickGrabGestureEvent() : _grab(false), _dragThreshold(QGuiApplication::styleHints()->startDragDistance()) {}
+ QQuickGrabGestureEvent() : _dragThreshold(QGuiApplication::styleHints()->startDragDistance()) {}
Q_INVOKABLE void grab() { _grab = true; }
bool wantsGrab() const { return _grab; }
@@ -209,7 +200,7 @@ public:
private:
friend class QQuickMultiPointTouchArea;
- bool _grab;
+ bool _grab = false;
qreal _dragThreshold;
QList<QObject*> _touchPoints;
};
diff --git a/src/quick/items/qquickspriteengine_p.h b/src/quick/items/qquickspriteengine_p.h
index 416e6611b5..d6d22b05d8 100644
--- a/src/quick/items/qquickspriteengine_p.h
+++ b/src/quick/items/qquickspriteengine_p.h
@@ -83,9 +83,6 @@ class Q_QUICK_PRIVATE_EXPORT QQuickStochasticState : public QObject //Currently
public:
QQuickStochasticState(QObject* parent = nullptr)
: QObject(parent)
- , m_duration(-1)
- , m_durationVariation(0)
- , m_randomStart(false)
{
}
@@ -179,11 +176,11 @@ public Q_SLOTS:
private:
QString m_name;
QVariantMap m_to;
- int m_duration;
- int m_durationVariation;
+ int m_duration = -1;
+ int m_durationVariation = 0;
friend class QQuickStochasticEngine;
- bool m_randomStart;
+ bool m_randomStart = false;
};
class Q_QUICK_PRIVATE_EXPORT QQuickStochasticEngine : public QObject