diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-02-21 11:52:59 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-02-26 13:08:30 +0000 |
commit | 06e962f263a86c4b66e1c6195b3d2615695fea1e (patch) | |
tree | 3669793f9983762538a9cb12a07ce49d461f066d /src/quick | |
parent | 78e875e6dbd4991fe22c194d8608b3d66c96e036 (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')
26 files changed, 192 insertions, 279 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 diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h index 46753e8087..918f3ce82c 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h @@ -125,7 +125,6 @@ template <typename Type, int PageSize> class Allocator { public: Allocator() - : m_freePage(0) { pages.push_back(new AllocatorPage<Type, PageSize>()); } @@ -209,7 +208,7 @@ public: } QVector<AllocatorPage<Type, PageSize> *> pages; - int m_freePage; + int m_freePage = 0; }; @@ -306,12 +305,7 @@ struct Buffer { struct Element { Element() - : node(nullptr) - , batch(nullptr) - , nextInBatch(nullptr) - , root(nullptr) - , order(0) - , boundsComputed(false) + : boundsComputed(false) , boundsOutsideFloatRange(false) , translateOnlyToRoot(false) , removed(false) @@ -332,14 +326,14 @@ struct Element { } void computeBounds(); - QSGGeometryNode *node; - Batch *batch; - Element *nextInBatch; - Node *root; + QSGGeometryNode *node = nullptr; + Batch *batch = nullptr; + Element *nextInBatch = nullptr; + Node *root = nullptr; Rect bounds; // in device coordinates - int order; + int order = 0; uint boundsComputed : 1; uint boundsOutsideFloatRange : 1; @@ -362,12 +356,12 @@ struct RenderNodeElement : public Element { }; struct BatchRootInfo { - BatchRootInfo() : parentRoot(nullptr), lastOrder(-1), firstOrder(-1), availableOrders(0) { } + BatchRootInfo() {} QSet<Node *> subRoots; - Node *parentRoot; - int lastOrder; - int firstOrder; - int availableOrders; + Node *parentRoot = nullptr; + int lastOrder = -1; + int firstOrder = -1; + int availableOrders = 0; }; struct ClipBatchRootInfo : public BatchRootInfo @@ -381,14 +375,13 @@ struct DrawSet : vertices(v) , zorders(z) , indices(i) - , indexCount(0) { } - DrawSet() : vertices(0), zorders(0), indices(0), indexCount(0) {} - int vertices; - int zorders; - int indices; - int indexCount; + DrawSet() {} + int vertices = 0; + int zorders = 0; + int indices = 0; + int indexCount = 0; }; enum BatchCompatibility diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp index 10d4e2a3eb..9717862baa 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.cpp +++ b/src/quick/scenegraph/coreapi/qsgnode.cpp @@ -244,14 +244,7 @@ static void qt_print_node_count() * Constructs a new node */ QSGNode::QSGNode() - : m_parent(nullptr) - , m_type(BasicNodeType) - , m_firstChild(nullptr) - , m_lastChild(nullptr) - , m_nextSibling(nullptr) - , m_previousSibling(nullptr) - , m_subtreeRenderableCount(0) - , m_nodeFlags(OwnedByParent) + : m_nodeFlags(OwnedByParent) , m_dirtyState(nullptr) { init(); @@ -870,10 +863,6 @@ void QSGBasicGeometryNode::setGeometry(QSGGeometry *geometry) QSGGeometryNode::QSGGeometryNode() : QSGBasicGeometryNode(GeometryNodeType) - , m_render_order(0) - , m_material(nullptr) - , m_opaque_material(nullptr) - , m_opacity(1) { } @@ -1326,8 +1315,6 @@ void QSGRootNode::notifyNodeChange(QSGNode *node, DirtyState state) */ QSGOpacityNode::QSGOpacityNode() : QSGNode(OpacityNodeType) - , m_opacity(1) - , m_combined_opacity(1) { } diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h index cd9d689dc1..528f100f8e 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.h +++ b/src/quick/scenegraph/coreapi/qsgnode.h @@ -168,13 +168,13 @@ private: void init(); void destroy(); - QSGNode *m_parent; - NodeType m_type; - QSGNode *m_firstChild; - QSGNode *m_lastChild; - QSGNode *m_nextSibling; - QSGNode *m_previousSibling; - int m_subtreeRenderableCount; + QSGNode *m_parent = nullptr; + NodeType m_type = BasicNodeType; + QSGNode *m_firstChild = nullptr; + QSGNode *m_lastChild = nullptr; + QSGNode *m_nextSibling = nullptr; + QSGNode *m_previousSibling = nullptr; + int m_subtreeRenderableCount = 0; Flags m_nodeFlags; DirtyState m_dirtyState; // Obsolete, remove in Qt 6 @@ -246,11 +246,11 @@ protected: private: friend class QSGNodeUpdater; - int m_render_order; - QSGMaterial *m_material; - QSGMaterial *m_opaque_material; + int m_render_order = 0; + QSGMaterial *m_material = nullptr; + QSGMaterial *m_opaque_material = nullptr; - qreal m_opacity; + qreal m_opacity = 1; }; class Q_QUICK_EXPORT QSGClipNode : public QSGBasicGeometryNode @@ -323,8 +323,8 @@ public: bool isSubtreeBlocked() const override; private: - qreal m_opacity; - qreal m_combined_opacity; + qreal m_opacity = 1; + qreal m_combined_opacity = 1; }; class Q_QUICK_EXPORT QSGNodeVisitor { diff --git a/src/quick/scenegraph/coreapi/qsgnode_p.h b/src/quick/scenegraph/coreapi/qsgnode_p.h index 84d5477085..f81128f51a 100644 --- a/src/quick/scenegraph/coreapi/qsgnode_p.h +++ b/src/quick/scenegraph/coreapi/qsgnode_p.h @@ -78,18 +78,14 @@ public: class QSGBasicGeometryNodePrivate : public QSGNodePrivate { public: - QSGBasicGeometryNodePrivate() - : QSGNodePrivate() - {} + QSGBasicGeometryNodePrivate() {} }; class QSGGeometryNodePrivate: public QSGBasicGeometryNodePrivate { public: - QSGGeometryNodePrivate() - : QSGBasicGeometryNodePrivate() - {} + QSGGeometryNodePrivate() {} }; QT_END_NAMESPACE diff --git a/src/quick/scenegraph/coreapi/qsgrenderer_p.h b/src/quick/scenegraph/coreapi/qsgrenderer_p.h index b890728fd8..d4ff6ea9fe 100644 --- a/src/quick/scenegraph/coreapi/qsgrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgrenderer_p.h @@ -162,12 +162,12 @@ class Q_QUICK_PRIVATE_EXPORT QSGNodeDumper : public QSGNodeVisitor { public: static void dump(QSGNode *n); - QSGNodeDumper() : m_indent(0) {} + QSGNodeDumper() {} void visitNode(QSGNode *n) override; void visitChildren(QSGNode *n) override; private: - int m_indent; + int m_indent = 0; }; diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h index f1d8493e85..9c88b8272c 100644 --- a/src/quick/scenegraph/qsgadaptationlayer_p.h +++ b/src/quick/scenegraph/qsgadaptationlayer_p.h @@ -266,19 +266,19 @@ public: Texture // for APIs with separate texture and sampler objects }; struct InputParameter { - InputParameter() : semanticIndex(0) { } + InputParameter() {} // Semantics use the D3D keys (POSITION, TEXCOORD). // Attribute name based APIs can map based on pre-defined names. QByteArray semanticName; - int semanticIndex; + int semanticIndex = 0; }; struct Variable { - Variable() : type(Constant), offset(0), size(0), bindPoint(0) { } - VariableType type; + Variable() {} + VariableType type = Constant; QByteArray name; - uint offset; // for cbuffer members - uint size; // for cbuffer members - int bindPoint; // for textures and samplers; for register-based APIs + uint offset = 0; // for cbuffer members + uint size = 0; // for cbuffer members + int bindPoint = 0; // for textures and samplers; for register-based APIs }; QByteArray blob; // source or bytecode @@ -329,8 +329,8 @@ public: }; struct ShaderData { - ShaderData() : hasShaderCode(false) { } - bool hasShaderCode; + ShaderData() {} + bool hasShaderCode = false; QSGGuiThreadShaderEffectManager::ShaderInfo shaderInfo; QVector<VariableData> varData; }; @@ -373,7 +373,7 @@ public: HighQualitySubPixelAntialiasing }; - QSGGlyphNode() : m_ownerElement(nullptr) {} + QSGGlyphNode() {} virtual void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) = 0; virtual void setColor(const QColor &color) = 0; @@ -394,7 +394,7 @@ public: void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } protected: QRectF m_bounding_rect; - QQuickItem *m_ownerElement; + QQuickItem *m_ownerElement = nullptr; }; class Q_QUICK_PRIVATE_EXPORT QSGDistanceFieldGlyphConsumer @@ -421,24 +421,24 @@ public: }; struct TexCoord { - qreal x; - qreal y; - qreal width; - qreal height; - qreal xMargin; - qreal yMargin; + qreal x = 0; + qreal y = 0; + qreal width = -1; + qreal height = -1; + qreal xMargin = 0; + qreal yMargin = 0; - TexCoord() : x(0), y(0), width(-1), height(-1), xMargin(0), yMargin(0) { } + TexCoord() {} bool isNull() const { return width <= 0 || height <= 0; } bool isValid() const { return width >= 0 && height >= 0; } }; struct Texture { - uint textureId; + uint textureId = 0; QSize size; - Texture() : textureId(0), size(QSize()) { } + Texture() : size(QSize()) { } bool operator == (const Texture &other) const { return textureId == other.textureId; } }; @@ -478,13 +478,13 @@ protected: }; struct GlyphData { - Texture *texture; + Texture *texture = nullptr; TexCoord texCoord; QRectF boundingRect; QPainterPath path; - quint32 ref; + quint32 ref = 0; - GlyphData() : texture(nullptr), ref(0) { } + GlyphData() {} }; virtual void requestGlyphs(const QSet<glyph_t> &glyphs) = 0; diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp index a697c315a3..628619fa46 100644 --- a/src/quick/scenegraph/qsgcontextplugin.cpp +++ b/src/quick/scenegraph/qsgcontextplugin.cpp @@ -74,8 +74,8 @@ struct QSGAdaptationBackendData { QSGAdaptationBackendData(); - bool tried; - QSGContextFactoryInterface *factory; + bool tried = false; + QSGContextFactoryInterface *factory = nullptr; QString name; QSGContextFactoryInterface::Flags flags; @@ -85,9 +85,7 @@ struct QSGAdaptationBackendData }; QSGAdaptationBackendData::QSGAdaptationBackendData() - : tried(false) - , factory(nullptr) - , flags(nullptr) + : flags(nullptr) { // Fill in the table with the built-in adaptations. builtIns.append(new QSGSoftwareAdaptation); diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h index fe365495c2..76c0d20647 100644 --- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h +++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h @@ -91,10 +91,9 @@ private: QSize size; QRect allocatedArea; QDistanceField image; - int padding; + int padding = -1; - TextureInfo(const QRect &preallocRect = QRect()) : texture(0), allocatedArea(preallocRect), padding(-1) - { } + TextureInfo(const QRect &preallocRect = QRect()) : texture(0), allocatedArea(preallocRect) { } }; void createTexture(TextureInfo * texInfo, int width, int height); diff --git a/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp b/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp index 7e6d6d0d07..5dd6eaa4ca 100644 --- a/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp +++ b/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp @@ -83,7 +83,6 @@ QSGMaterialShader *QSGSmoothTextureMaterial::createShader() const } SmoothTextureMaterialShader::SmoothTextureMaterialShader() - : QSGTextureMaterialShader() { setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/smoothtexture.vert")); setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/smoothtexture.frag")); diff --git a/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp b/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp index ef8a13931e..fd0dcebd57 100644 --- a/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp +++ b/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp @@ -67,7 +67,6 @@ private: }; SmoothColorMaterialShader::SmoothColorMaterialShader() - : QSGMaterialShader() { setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/smoothcolor.vert")); setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/smoothcolor.frag")); diff --git a/src/quick/scenegraph/qsgdefaultspritenode.cpp b/src/quick/scenegraph/qsgdefaultspritenode.cpp index c9a9625f2b..8761d99c1f 100644 --- a/src/quick/scenegraph/qsgdefaultspritenode.cpp +++ b/src/quick/scenegraph/qsgdefaultspritenode.cpp @@ -70,26 +70,18 @@ public: return this - static_cast<const QQuickSpriteMaterial *>(other); } - QSGTexture *texture; - - float animT; - float animX1; - float animY1; - float animX2; - float animY2; - float animW; - float animH; + QSGTexture *texture = nullptr; + + float animT = 0.0f; + float animX1 = 0.0f; + float animY1 = 0.0f; + float animX2 = 0.0f; + float animY2 = 0.0f; + float animW = 1.0f; + float animH = 1.0f; }; QQuickSpriteMaterial::QQuickSpriteMaterial() - : texture(nullptr) - , animT(0.0f) - , animX1(0.0f) - , animY1(0.0f) - , animX2(0.0f) - , animY2(0.0f) - , animW(1.0f) - , animH(1.0f) { setFlag(Blending, true); } @@ -103,7 +95,6 @@ class SpriteMaterialData : public QSGMaterialShader { public: SpriteMaterialData() - : QSGMaterialShader() { setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/sprite.vert")); setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/sprite.frag")); diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp index dd2d787495..aa58218505 100644 --- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp @@ -61,19 +61,19 @@ protected: void updateColor(const QVector4D &c); void updateTextureScale(const QVector2D &ts); - float m_fontScale; - float m_matrixScale; + float m_fontScale = 1.0; + float m_matrixScale = 1.0; - int m_matrix_id; - int m_textureScale_id; - int m_alphaMin_id; - int m_alphaMax_id; - int m_color_id; + int m_matrix_id = -1; + int m_textureScale_id = -1; + int m_alphaMin_id = -1; + int m_alphaMax_id = -1; + int m_color_id = -1; QVector2D m_lastTextureScale; QVector4D m_lastColor; - float m_lastAlphaMin; - float m_lastAlphaMax; + float m_lastAlphaMin = -1; + float m_lastAlphaMax = -1; }; char const *const *QSGDistanceFieldTextMaterialShader::attributeNames() const { @@ -82,16 +82,6 @@ char const *const *QSGDistanceFieldTextMaterialShader::attributeNames() const { } QSGDistanceFieldTextMaterialShader::QSGDistanceFieldTextMaterialShader() - : QSGMaterialShader(), - m_fontScale(1.0) - , m_matrixScale(1.0) - , m_matrix_id(-1) - , m_textureScale_id(-1) - , m_alphaMin_id(-1) - , m_alphaMax_id(-1) - , m_color_id(-1) - , m_lastAlphaMin(-1) - , m_lastAlphaMax(-1) { setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldtext.vert")); setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldtext.frag")); @@ -288,12 +278,11 @@ public: protected: void initialize() override; - int m_styleColor_id; + int m_styleColor_id = -1; }; DistanceFieldStyledTextMaterialShader::DistanceFieldStyledTextMaterialShader() : QSGDistanceFieldTextMaterialShader() - , m_styleColor_id(-1) { } @@ -358,14 +347,12 @@ protected: void updateOutlineAlphaRange(int dfRadius); - int m_outlineAlphaMax0_id; - int m_outlineAlphaMax1_id; + int m_outlineAlphaMax0_id = -1; + int m_outlineAlphaMax1_id = -1; }; DistanceFieldOutlineTextMaterialShader::DistanceFieldOutlineTextMaterialShader() : DistanceFieldStyledTextMaterialShader() - , m_outlineAlphaMax0_id(-1) - , m_outlineAlphaMax1_id(-1) { setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldoutlinetext.frag")); } @@ -438,12 +425,11 @@ protected: void updateShift(qreal fontScale, const QPointF& shift); - int m_shift_id; + int m_shift_id = -1; }; DistanceFieldShiftedStyleTextMaterialShader::DistanceFieldShiftedStyleTextMaterialShader() : DistanceFieldStyledTextMaterialShader() - , m_shift_id(-1) { setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldshiftedtext.vert")); setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldshiftedtext.frag")); @@ -516,14 +502,12 @@ public: void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; private: - int m_fontScale_id; - int m_vecDelta_id; + int m_fontScale_id = -1; + int m_vecDelta_id = -1; }; QSGHiQSubPixelDistanceFieldTextMaterialShader::QSGHiQSubPixelDistanceFieldTextMaterialShader() : QSGDistanceFieldTextMaterialShader() - , m_fontScale_id(-1) - , m_vecDelta_id(-1) { setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/hiqsubpixeldistancefieldtext.vert")); setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/hiqsubpixeldistancefieldtext.frag")); diff --git a/src/quick/scenegraph/util/qsgsimpletexturenode.cpp b/src/quick/scenegraph/util/qsgsimpletexturenode.cpp index 6ce37de7cb..0c49ca9aa5 100644 --- a/src/quick/scenegraph/util/qsgsimpletexturenode.cpp +++ b/src/quick/scenegraph/util/qsgsimpletexturenode.cpp @@ -47,8 +47,7 @@ class QSGSimpleTextureNodePrivate : public QSGGeometryNodePrivate { public: QSGSimpleTextureNodePrivate() - : QSGGeometryNodePrivate() - , texCoordMode(QSGSimpleTextureNode::NoTransform) + : texCoordMode(QSGSimpleTextureNode::NoTransform) , isAtlasTexture(false) , ownsTexture(false) {} diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp index 70a8b321d8..7b1d5abb26 100644 --- a/src/quick/scenegraph/util/qsgtexturematerial.cpp +++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp @@ -57,7 +57,6 @@ inline static bool isPowerOfTwo(int x) QSGMaterialType QSGOpaqueTextureMaterialShader::type; QSGOpaqueTextureMaterialShader::QSGOpaqueTextureMaterialShader() - : QSGMaterialShader() { #if QT_CONFIG(opengl) setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/opaquetexture.vert")); diff --git a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp index f1ad73af1b..cb61430e2e 100644 --- a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp +++ b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp @@ -64,7 +64,6 @@ private: QSGMaterialType QSGVertexColorMaterialShader::type; QSGVertexColorMaterialShader::QSGVertexColorMaterialShader() - : QSGMaterialShader() { #if QT_CONFIG(opengl) setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/vertexcolor.vert")); diff --git a/src/quick/util/qquickfontloader.cpp b/src/quick/util/qquickfontloader.cpp index 72b9149886..2da541304d 100644 --- a/src/quick/util/qquickfontloader.cpp +++ b/src/quick/util/qquickfontloader.cpp @@ -77,8 +77,8 @@ Q_SIGNALS: void fontDownloaded(const QString&, QQuickFontLoader::Status); private: - int redirectCount; - QNetworkReply *reply; + int redirectCount = 0; + QNetworkReply *reply = nullptr; private Q_SLOTS: void replyFinished(); @@ -91,13 +91,8 @@ public: }; QQuickFontObject::QQuickFontObject(int _id) - : QObject(nullptr) -#if QT_CONFIG(qml_network) - ,redirectCount(0), reply(nullptr) -#endif - ,id(_id) + : QObject(nullptr), id(_id) { - } #if QT_CONFIG(qml_network) @@ -148,11 +143,11 @@ class QQuickFontLoaderPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QQuickFontLoader) public: - QQuickFontLoaderPrivate() : status(QQuickFontLoader::Null) {} + QQuickFontLoaderPrivate() {} QUrl url; QString name; - QQuickFontLoader::Status status; + QQuickFontLoader::Status status = QQuickFontLoader::Null; }; static void q_QFontLoaderFontsStaticReset(); diff --git a/src/quick/util/qquickimageprovider.cpp b/src/quick/util/qquickimageprovider.cpp index e7891a6612..1a13f6395a 100644 --- a/src/quick/util/qquickimageprovider.cpp +++ b/src/quick/util/qquickimageprovider.cpp @@ -515,15 +515,12 @@ class QQuickImageProviderOptionsPrivate : public QSharedData { public: QQuickImageProviderOptionsPrivate() - : autoTransform(QQuickImageProviderOptions::UsePluginDefaultTransform) - , preserveAspectRatioCrop(false) - , preserveAspectRatioFit(false) { } - QQuickImageProviderOptions::AutoTransform autoTransform; - bool preserveAspectRatioCrop; - bool preserveAspectRatioFit; + QQuickImageProviderOptions::AutoTransform autoTransform = QQuickImageProviderOptions::UsePluginDefaultTransform; + bool preserveAspectRatioCrop = false; + bool preserveAspectRatioFit = false; }; /*! diff --git a/src/quick/util/qquickpath_p.h b/src/quick/util/qquickpath_p.h index 06f6800a0e..f8b67ef945 100644 --- a/src/quick/util/qquickpath_p.h +++ b/src/quick/util/qquickpath_p.h @@ -90,7 +90,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathAttribute : public QQuickPathElement Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) public: - QQuickPathAttribute(QObject *parent=nullptr) : QQuickPathElement(parent), _value(0) {} + QQuickPathAttribute(QObject *parent=nullptr) : QQuickPathElement(parent) {} QString name() const; @@ -105,7 +105,7 @@ Q_SIGNALS: private: QString _name; - qreal _value; + qreal _value = 0; }; class Q_QUICK_PRIVATE_EXPORT QQuickCurve : public QQuickPathElement @@ -177,7 +177,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathQuad : public QQuickCurve Q_PROPERTY(qreal relativeControlX READ relativeControlX WRITE setRelativeControlX NOTIFY relativeControlXChanged) Q_PROPERTY(qreal relativeControlY READ relativeControlY WRITE setRelativeControlY NOTIFY relativeControlYChanged) public: - QQuickPathQuad(QObject *parent=nullptr) : QQuickCurve(parent), _controlX(0), _controlY(0) {} + QQuickPathQuad(QObject *parent=nullptr) : QQuickCurve(parent) {} qreal controlX() const; void setControlX(qreal x); @@ -202,8 +202,8 @@ Q_SIGNALS: void relativeControlYChanged(); private: - qreal _controlX; - qreal _controlY; + qreal _controlX = 0; + qreal _controlY = 0; QQmlNullableValue<qreal> _relativeControlX; QQmlNullableValue<qreal> _relativeControlY; }; @@ -221,7 +221,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathCubic : public QQuickCurve Q_PROPERTY(qreal relativeControl2X READ relativeControl2X WRITE setRelativeControl2X NOTIFY relativeControl2XChanged) Q_PROPERTY(qreal relativeControl2Y READ relativeControl2Y WRITE setRelativeControl2Y NOTIFY relativeControl2YChanged) public: - QQuickPathCubic(QObject *parent=nullptr) : QQuickCurve(parent), _control1X(0), _control1Y(0), _control2X(0), _control2Y(0) {} + QQuickPathCubic(QObject *parent=nullptr) : QQuickCurve(parent) {} qreal control1X() const; void setControl1X(qreal x); @@ -264,10 +264,10 @@ Q_SIGNALS: void relativeControl2YChanged(); private: - qreal _control1X; - qreal _control1Y; - qreal _control2X; - qreal _control2Y; + qreal _control1X = 0; + qreal _control1Y = 0; + qreal _control2X = 0; + qreal _control2Y = 0; QQmlNullableValue<qreal> _relativeControl1X; QQmlNullableValue<qreal> _relativeControl1Y; QQmlNullableValue<qreal> _relativeControl2X; @@ -294,7 +294,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathArc : public QQuickCurve public: QQuickPathArc(QObject *parent=nullptr) - : QQuickCurve(parent), _radiusX(0), _radiusY(0), _useLargeArc(false), _direction(Clockwise), _xAxisRotation(0) {} + : QQuickCurve(parent) {} enum ArcDirection { Clockwise, Counterclockwise }; Q_ENUM(ArcDirection) @@ -324,11 +324,11 @@ Q_SIGNALS: Q_REVISION(2) void xAxisRotationChanged(); private: - qreal _radiusX; - qreal _radiusY; - bool _useLargeArc; - ArcDirection _direction; - qreal _xAxisRotation; + qreal _radiusX = 0; + qreal _radiusY = 0; + bool _useLargeArc = false; + ArcDirection _direction = Clockwise; + qreal _xAxisRotation = 0; }; class Q_QUICK_PRIVATE_EXPORT QQuickPathAngleArc : public QQuickCurve @@ -344,7 +344,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathAngleArc : public QQuickCurve public: QQuickPathAngleArc(QObject *parent=nullptr) - : QQuickCurve(parent), _centerX(0), _centerY(0), _radiusX(0), _radiusY(0), _startAngle(0), _sweepAngle(0), _moveToStart(true) {} + : QQuickCurve(parent) {} qreal centerX() const; void setCenterX(qreal); @@ -379,13 +379,13 @@ Q_SIGNALS: void moveToStartChanged(); private: - qreal _centerX; - qreal _centerY; - qreal _radiusX; - qreal _radiusY; - qreal _startAngle; - qreal _sweepAngle; - bool _moveToStart; + qreal _centerX = 0; + qreal _centerY = 0; + qreal _radiusX = 0; + qreal _radiusY = 0; + qreal _startAngle = 0; + qreal _sweepAngle = 0; + bool _moveToStart = true; }; class Q_QUICK_PRIVATE_EXPORT QQuickPathSvg : public QQuickCurve @@ -412,7 +412,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathPercent : public QQuickPathElement Q_OBJECT Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) public: - QQuickPathPercent(QObject *parent=nullptr) : QQuickPathElement(parent), _value(0) {} + QQuickPathPercent(QObject *parent=nullptr) : QQuickPathElement(parent) {} qreal value() const; void setValue(qreal value); @@ -421,18 +421,18 @@ Q_SIGNALS: void valueChanged(); private: - qreal _value; + qreal _value = 0; }; struct QQuickCachedBezier { - QQuickCachedBezier() : isValid(false) {} + QQuickCachedBezier() {} QBezier bezier; int element; qreal bezLength; qreal currLength; qreal p; - bool isValid; + bool isValid = false; }; class QQuickPathPrivate; @@ -494,15 +494,15 @@ private Q_SLOTS: private: struct AttributePoint { - AttributePoint() : percent(0), scale(1), origpercent(0) {} + AttributePoint() {} AttributePoint(const AttributePoint &other) : percent(other.percent), scale(other.scale), origpercent(other.origpercent), values(other.values) {} AttributePoint &operator=(const AttributePoint &other) { percent = other.percent; scale = other.scale; origpercent = other.origpercent; values = other.values; return *this; } - qreal percent; //massaged percent along the painter path - qreal scale; - qreal origpercent; //'real' percent along the painter path + qreal percent = 0; //massaged percent along the painter path + qreal scale = 1; + qreal origpercent = 0; //'real' percent along the painter path QHash<QString, qreal> values; }; diff --git a/src/quick/util/qquickpath_p_p.h b/src/quick/util/qquickpath_p_p.h index f5c9664223..9735d51264 100644 --- a/src/quick/util/qquickpath_p_p.h +++ b/src/quick/util/qquickpath_p_p.h @@ -72,7 +72,7 @@ public: static QQuickPathPrivate* get(QQuickPath *path) { return path->d_func(); } static const QQuickPathPrivate* get(const QQuickPath *path) { return path->d_func(); } - QQuickPathPrivate() : pathLength(0), closed(false), componentComplete(true), isShapePath(false) { } + QQuickPathPrivate() {} QPainterPath _path; QList<QQuickPathElement*> _pathElements; @@ -83,10 +83,10 @@ public: mutable QQuickCachedBezier prevBez; QQmlNullableValue<qreal> startX; QQmlNullableValue<qreal> startY; - qreal pathLength; - bool closed; - bool componentComplete; - bool isShapePath; + qreal pathLength = 0; + bool closed = false; + bool componentComplete = true; + bool isShapePath = false; }; QT_END_NAMESPACE diff --git a/src/quick/util/qquickstyledtext_p.h b/src/quick/util/qquickstyledtext_p.h index 821f95b6bf..51f1b7d8f9 100644 --- a/src/quick/util/qquickstyledtext_p.h +++ b/src/quick/util/qquickstyledtext_p.h @@ -67,9 +67,7 @@ class QQmlContext; class Q_AUTOTEST_EXPORT QQuickStyledTextImgTag { public: - QQuickStyledTextImgTag() - : position(0), offset(0.0), align(QQuickStyledTextImgTag::Bottom), pix(nullptr) - { } + QQuickStyledTextImgTag() { } ~QQuickStyledTextImgTag() { delete pix; } @@ -82,10 +80,10 @@ public: QUrl url; QPointF pos; QSize size; - int position; - qreal offset; // this offset allows us to compensate for flooring reserved space - Align align; - QQuickPixmap *pix; + int position = 0; + qreal offset = 0.0; // this offset allows us to compensate for flooring reserved space + Align align = QQuickStyledTextImgTag::Bottom; + QQuickPixmap *pix = nullptr; }; class Q_AUTOTEST_EXPORT QQuickStyledText diff --git a/src/quick/util/qquicktimeline.cpp b/src/quick/util/qquicktimeline.cpp index 93284c0685..ac9f75979e 100644 --- a/src/quick/util/qquicktimeline.cpp +++ b/src/quick/util/qquicktimeline.cpp @@ -104,11 +104,11 @@ struct QQuickTimeLinePrivate }; struct TimeLine { - TimeLine() : length(0), consumedOpLength(0), base(0.) {} + TimeLine() {} QList<Op> ops; - int length; - int consumedOpLength; - qreal base; + int length = 0; + int consumedOpLength = 0; + qreal base = 0.; }; int length; |