From 06e962f263a86c4b66e1c6195b3d2615695fea1e Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 21 Feb 2018 11:52:59 +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='qtdeclarative' -fix Change-Id: I705f3235ff129ba68b0d8dad54a083e29fcead5f Reviewed-by: Johan Helsing --- src/qml/animations/qanimationgroupjob_p.h | 4 +- .../animations/qcontinuinganimationgroupjob.cpp | 1 - src/qml/animations/qparallelanimationgroupjob_p.h | 4 +- src/qml/animations/qpauseanimationjob.cpp | 3 +- .../animations/qsequentialanimationgroupjob_p.h | 12 ++--- src/qml/compiler/qqmlirbuilder_p.h | 24 ++++------ src/qml/compiler/qv4codegen_p.h | 37 +++++---------- src/qml/compiler/qv4compilercontext_p.h | 6 +-- src/qml/jsruntime/qv4executableallocator_p.h | 18 +++---- src/qml/jsruntime/qv4identifier_p.h | 4 +- src/qml/jsruntime/qv4persistent_p.h | 8 ++-- src/qml/parser/qqmljsast_p.h | 11 ++--- src/qml/parser/qqmljsengine_p.h | 5 +- src/qml/parser/qqmljsmemorypool_p.h | 18 +++---- src/qml/qml/ftw/qflagpointer_p.h | 6 +-- src/qml/qml/ftw/qhashedstring_p.h | 55 ++++++++++------------ src/qml/qml/ftw/qintrusivelist_p.h | 9 ++-- src/qml/qml/ftw/qqmlnullablevalue_p.h | 4 +- src/qml/qml/qqmlabstractbinding_p.h | 4 +- src/qml/qml/qqmlboundsignalexpressionpointer_p.h | 4 +- src/qml/qml/qqmldirparser_p.h | 18 ++++--- src/qml/qml/qqmlglobal_p.h | 6 +-- src/qml/qml/qqmlguard_p.h | 11 ++--- src/qml/qml/qqmllist.h | 30 +++++------- src/qml/qml/qqmlnotifier_p.h | 3 +- src/qml/qml/qqmlpropertycache_p.h | 4 +- src/qml/types/qqmltimer.cpp | 4 +- src/qml/util/qqmlchangeset_p.h | 6 +-- src/qml/util/qqmllistcompositor_p.h | 21 ++++----- 29 files changed, 141 insertions(+), 199 deletions(-) (limited to 'src/qml') diff --git a/src/qml/animations/qanimationgroupjob_p.h b/src/qml/animations/qanimationgroupjob_p.h index 26965c0264..42a73aa77b 100644 --- a/src/qml/animations/qanimationgroupjob_p.h +++ b/src/qml/animations/qanimationgroupjob_p.h @@ -90,8 +90,8 @@ protected: private: //definition - QAbstractAnimationJob *m_firstChild; - QAbstractAnimationJob *m_lastChild; + QAbstractAnimationJob *m_firstChild = nullptr; + QAbstractAnimationJob *m_lastChild = nullptr; }; QT_END_NAMESPACE diff --git a/src/qml/animations/qcontinuinganimationgroupjob.cpp b/src/qml/animations/qcontinuinganimationgroupjob.cpp index 02dcaf1313..10096bf19c 100644 --- a/src/qml/animations/qcontinuinganimationgroupjob.cpp +++ b/src/qml/animations/qcontinuinganimationgroupjob.cpp @@ -43,7 +43,6 @@ QT_BEGIN_NAMESPACE QContinuingAnimationGroupJob::QContinuingAnimationGroupJob() - : QAnimationGroupJob() { } diff --git a/src/qml/animations/qparallelanimationgroupjob_p.h b/src/qml/animations/qparallelanimationgroupjob_p.h index 358b95ce53..67ba626247 100644 --- a/src/qml/animations/qparallelanimationgroupjob_p.h +++ b/src/qml/animations/qparallelanimationgroupjob_p.h @@ -76,8 +76,8 @@ private: void applyGroupState(QAbstractAnimationJob *animation); //state - int m_previousLoop; - int m_previousCurrentTime; + int m_previousLoop = 0; + int m_previousCurrentTime = 0; }; QT_END_NAMESPACE diff --git a/src/qml/animations/qpauseanimationjob.cpp b/src/qml/animations/qpauseanimationjob.cpp index 27175580dc..0652ed578b 100644 --- a/src/qml/animations/qpauseanimationjob.cpp +++ b/src/qml/animations/qpauseanimationjob.cpp @@ -42,8 +42,7 @@ QT_BEGIN_NAMESPACE QPauseAnimationJob::QPauseAnimationJob(int duration) - : QAbstractAnimationJob() - , m_duration(duration) + : m_duration(duration) { m_isPause = true; } diff --git a/src/qml/animations/qsequentialanimationgroupjob_p.h b/src/qml/animations/qsequentialanimationgroupjob_p.h index c7023b77c6..800f0c3b90 100644 --- a/src/qml/animations/qsequentialanimationgroupjob_p.h +++ b/src/qml/animations/qsequentialanimationgroupjob_p.h @@ -77,12 +77,12 @@ protected: private: struct AnimationIndex { - AnimationIndex() : afterCurrent(false), timeOffset(0), animation(nullptr) {} + AnimationIndex() {} // AnimationIndex points to the animation at timeOffset, skipping 0 duration animations. // Note that the index semantic is slightly different depending on the direction. - bool afterCurrent; //whether animation is before or after m_currentAnimation //TODO: make enum Before/After/Same - int timeOffset; // time offset when the animation at index starts. - QAbstractAnimationJob *animation; //points to the animation at timeOffset + bool afterCurrent = false; //whether animation is before or after m_currentAnimation //TODO: make enum Before/After/Same + int timeOffset = 0; // time offset when the animation at index starts. + QAbstractAnimationJob *animation = nullptr; //points to the animation at timeOffset }; int animationActualTotalDuration(QAbstractAnimationJob *anim) const; @@ -103,8 +103,8 @@ private: void advanceForwards(const AnimationIndex &newAnimationIndex); //state - QAbstractAnimationJob *m_currentAnimation; - int m_previousLoop; + QAbstractAnimationJob *m_currentAnimation = nullptr; + int m_previousLoop = 0; }; QT_END_NAMESPACE diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h index 673bc2c481..7f2cf40611 100644 --- a/src/qml/compiler/qqmlirbuilder_p.h +++ b/src/qml/compiler/qqmlirbuilder_p.h @@ -82,12 +82,11 @@ struct PoolList PoolList() : first(nullptr) , last(nullptr) - , count(0) {} T *first; T *last; - int count; + int count = 0; int append(T *item) { item->next = nullptr; @@ -205,11 +204,11 @@ class FixedPoolArray { T *data; public: - int count; + int count = 0; FixedPoolArray() : data(nullptr) - , count(0) + {} void allocate(QQmlJS::MemoryPool *pool, int size) @@ -343,21 +342,16 @@ struct Function struct Q_QML_PRIVATE_EXPORT CompiledFunctionOrExpression { CompiledFunctionOrExpression() - : node(nullptr) - , nameIndex(0) - , disableAcceleratedLookups(false) - , next(nullptr) + {} CompiledFunctionOrExpression(QQmlJS::AST::Node *n) : node(n) - , nameIndex(0) - , disableAcceleratedLookups(false) - , next(nullptr) + {} - QQmlJS::AST::Node *node; // FunctionDeclaration, Statement or Expression - quint32 nameIndex; - bool disableAcceleratedLookups; - CompiledFunctionOrExpression *next; + QQmlJS::AST::Node *node = nullptr; // FunctionDeclaration, Statement or Expression + quint32 nameIndex = 0; + bool disableAcceleratedLookups = false; + CompiledFunctionOrExpression *next = nullptr; }; struct Q_QML_PRIVATE_EXPORT Object diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h index 27c8e96e16..a46d47cb67 100644 --- a/src/qml/compiler/qv4codegen_p.h +++ b/src/qml/compiler/qv4codegen_p.h @@ -191,10 +191,7 @@ public: bool isLValue() const { return !isReadonly; } Reference(Codegen *cg, Type type = Invalid) : type(type), codegen(cg) {} - Reference() - : type(Invalid) - , codegen(nullptr) - {} + Reference() {} Reference(const Reference &other); Reference &operator =(const Reference &other); @@ -367,7 +364,7 @@ public: bool stackSlotIsLocalOrArgument = false; bool isVolatile = false; bool global = false; - Codegen *codegen; + Codegen *codegen = nullptr; private: void storeAccumulator() const; @@ -386,16 +383,12 @@ public: }; struct ObjectPropertyValue { - ObjectPropertyValue() - : getter(-1) - , setter(-1) - , keyAsIndex(UINT_MAX) - {} + ObjectPropertyValue() {} Reference rvalue; - int getter; // index in _module->functions or -1 if not set - int setter; - uint keyAsIndex; + int getter = -1; // index in _module->functions or -1 if not set + int setter = -1; + uint keyAsIndex = UINT_MAX; bool hasGetter() const { return getter >= 0; } bool hasSetter() const { return setter >= 0; } @@ -406,34 +399,26 @@ protected: class Result { Reference _result; - const BytecodeGenerator::Label *_iftrue; - const BytecodeGenerator::Label *_iffalse; - Format _format; + const BytecodeGenerator::Label *_iftrue = nullptr; + const BytecodeGenerator::Label *_iffalse = nullptr; + Format _format = ex; Format _requested; bool _trueBlockFollowsCondition = false; public: explicit Result(const Reference &lrvalue) : _result(lrvalue) - , _iftrue(nullptr) - , _iffalse(nullptr) - , _format(ex) , _requested(ex) - { - } + {} explicit Result(Format requested = ex) - : _iftrue(nullptr) - , _iffalse(nullptr) - , _format(ex) - , _requested(requested) {} + : _requested(requested) {} explicit Result(const BytecodeGenerator::Label *iftrue, const BytecodeGenerator::Label *iffalse, bool trueBlockFollowsCondition) : _iftrue(iftrue) , _iffalse(iffalse) - , _format(ex) , _requested(cx) , _trueBlockFollowsCondition(trueBlockFollowsCondition) { diff --git a/src/qml/compiler/qv4compilercontext_p.h b/src/qml/compiler/qv4compilercontext_p.h index d375942d0e..a78a66db52 100644 --- a/src/qml/compiler/qv4compilercontext_p.h +++ b/src/qml/compiler/qv4compilercontext_p.h @@ -173,10 +173,10 @@ struct Context { // Map from meta property index (existence implies dependency) to notify signal index struct KeyValuePair { - quint32 _key; - quint32 _value; + quint32 _key = 0; + quint32 _value = 0; - KeyValuePair(): _key(0), _value(0) {} + KeyValuePair() {} KeyValuePair(quint32 key, quint32 value): _key(key), _value(value) {} quint32 key() const { return _key; } diff --git a/src/qml/jsruntime/qv4executableallocator_p.h b/src/qml/jsruntime/qv4executableallocator_p.h index 2984a89df5..375c9a365f 100644 --- a/src/qml/jsruntime/qv4executableallocator_p.h +++ b/src/qml/jsruntime/qv4executableallocator_p.h @@ -82,11 +82,8 @@ public: struct Allocation { Allocation() - : addr(0) - , size(0) + : size(0) , free(true) - , next(nullptr) - , prev(nullptr) {} void *start() const; @@ -103,11 +100,11 @@ public: bool mergeNext(ExecutableAllocator *allocator); bool mergePrevious(ExecutableAllocator *allocator); - quintptr addr; + quintptr addr = 0; uint size : 31; // More than 2GB of function code? nah :) uint free : 1; - Allocation *next; - Allocation *prev; + Allocation *next = nullptr; + Allocation *prev = nullptr; }; // for debugging / unit-testing @@ -117,13 +114,12 @@ public: struct ChunkOfPages { ChunkOfPages() - : pages(nullptr) - , firstAllocation(nullptr) + {} ~ChunkOfPages(); - WTF::PageAllocation *pages; - Allocation *firstAllocation; + WTF::PageAllocation *pages = nullptr; + Allocation *firstAllocation = nullptr; bool contains(Allocation *alloc) const; }; diff --git a/src/qml/jsruntime/qv4identifier_p.h b/src/qml/jsruntime/qv4identifier_p.h index 21e4e8ea66..82346d5f68 100644 --- a/src/qml/jsruntime/qv4identifier_p.h +++ b/src/qml/jsruntime/qv4identifier_p.h @@ -95,9 +95,9 @@ struct IdentifierHashData struct IdentifierHash { - IdentifierHashData *d; + IdentifierHashData *d = nullptr; - IdentifierHash() : d(nullptr) {} + IdentifierHash() {} IdentifierHash(ExecutionEngine *engine); inline IdentifierHash(const IdentifierHash &other); inline ~IdentifierHash(); diff --git a/src/qml/jsruntime/qv4persistent_p.h b/src/qml/jsruntime/qv4persistent_p.h index 5a0b2389e1..55e8eefcb7 100644 --- a/src/qml/jsruntime/qv4persistent_p.h +++ b/src/qml/jsruntime/qv4persistent_p.h @@ -94,7 +94,7 @@ private: class Q_QML_EXPORT PersistentValue { public: - PersistentValue() : val(nullptr) {} + PersistentValue() {} PersistentValue(const PersistentValue &other); PersistentValue &operator=(const PersistentValue &other); PersistentValue &operator=(const WeakValue &other); @@ -142,13 +142,13 @@ public: bool isEmpty() { return !val; } private: - Value *val; + Value *val = nullptr; }; class Q_QML_EXPORT WeakValue { public: - WeakValue() : val(nullptr) {} + WeakValue() {} WeakValue(const WeakValue &other); WeakValue(ExecutionEngine *engine, const Value &value); WeakValue &operator=(const WeakValue &other); @@ -206,7 +206,7 @@ public: void markOnce(MarkStack *markStack); private: - Value *val; + Value *val = nullptr; private: Q_NEVER_INLINE void allocVal(ExecutionEngine *engine); diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h index acbd88d466..ed3c83badf 100644 --- a/src/qml/parser/qqmljsast_p.h +++ b/src/qml/parser/qqmljsast_p.h @@ -224,8 +224,7 @@ public: Kind_UiEnumMemberList }; - inline Node() - : kind(Kind_Undefined) {} + inline Node() {} // NOTE: node destructors are never called, // instead we block free the memory @@ -248,7 +247,7 @@ public: virtual SourceLocation lastSourceLocation() const = 0; // attributes - int kind; + int kind = Kind_Undefined; }; class QML_PARSER_EXPORT ExpressionNode: public Node @@ -489,8 +488,8 @@ class QML_PARSER_EXPORT ObjectLiteral: public ExpressionNode public: QQMLJS_DECLARE_AST_NODE(ObjectLiteral) - ObjectLiteral(): - properties (nullptr) { kind = K; } + ObjectLiteral() + { kind = K; } ObjectLiteral(PropertyAssignmentList *plist): properties (plist) { kind = K; } @@ -504,7 +503,7 @@ public: { return rbraceToken; } // attributes - PropertyAssignmentList *properties; + PropertyAssignmentList *properties = nullptr; SourceLocation lbraceToken; SourceLocation rbraceToken; }; diff --git a/src/qml/parser/qqmljsengine_p.h b/src/qml/parser/qqmljsengine_p.h index 8cbe69a0ba..af26bac0ff 100644 --- a/src/qml/parser/qqmljsengine_p.h +++ b/src/qml/parser/qqmljsengine_p.h @@ -71,8 +71,7 @@ class QML_PARSER_EXPORT DiagnosticMessage public: enum Kind { Warning, Error }; - DiagnosticMessage() - : kind(Error) {} + DiagnosticMessage() {} DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message) : kind(kind), loc(loc), message(message) {} @@ -83,7 +82,7 @@ public: bool isError() const { return kind == Error; } - Kind kind; + Kind kind = Error; AST::SourceLocation loc; QString message; }; diff --git a/src/qml/parser/qqmljsmemorypool_p.h b/src/qml/parser/qqmljsmemorypool_p.h index 5682d66f45..ef443d96bc 100644 --- a/src/qml/parser/qqmljsmemorypool_p.h +++ b/src/qml/parser/qqmljsmemorypool_p.h @@ -71,13 +71,7 @@ class QML_PARSER_EXPORT MemoryPool : public QSharedData void operator =(const MemoryPool &other); public: - MemoryPool() - : _blocks(nullptr), - _allocatedBlocks(0), - _blockCount(-1), - _ptr(nullptr), - _end(nullptr) - { } + MemoryPool() {} ~MemoryPool() { @@ -144,11 +138,11 @@ private: } private: - char **_blocks; - int _allocatedBlocks; - int _blockCount; - char *_ptr; - char *_end; + char **_blocks = nullptr; + int _allocatedBlocks = 0; + int _blockCount = -1; + char *_ptr = nullptr; + char *_end = nullptr; enum { diff --git a/src/qml/qml/ftw/qflagpointer_p.h b/src/qml/qml/ftw/qflagpointer_p.h index 6954a8f09c..91ce74bec9 100644 --- a/src/qml/qml/ftw/qflagpointer_p.h +++ b/src/qml/qml/ftw/qflagpointer_p.h @@ -83,7 +83,7 @@ public: inline T *data() const; private: - quintptr ptr_value; + quintptr ptr_value = 0; static const quintptr FlagBit = 0x1; static const quintptr Flag2Bit = 0x2; @@ -115,7 +115,7 @@ public: inline T2 *asT2() const; private: - quintptr ptr_value; + quintptr ptr_value = 0; static const quintptr FlagBit = 0x1; static const quintptr Flag2Bit = 0x2; @@ -124,7 +124,6 @@ private: template QFlagPointer::QFlagPointer() -: ptr_value(0) { } @@ -233,7 +232,6 @@ T *QFlagPointer::data() const template QBiPointer::QBiPointer() -: ptr_value(0) { } diff --git a/src/qml/qml/ftw/qhashedstring_p.h b/src/qml/qml/ftw/qhashedstring_p.h index bd2c9fbdb7..2d6c25bdd3 100644 --- a/src/qml/qml/ftw/qhashedstring_p.h +++ b/src/qml/qml/ftw/qhashedstring_p.h @@ -94,7 +94,7 @@ private: friend class QStringHashNode; inline void computeHash() const; - mutable quint32 m_hash; + mutable quint32 m_hash = 0; }; class QHashedCStringRef; @@ -142,9 +142,9 @@ private: inline void computeHash() const; - const QChar *m_data; - int m_length; - mutable quint32 m_hash; + const QChar *m_data = nullptr; + int m_length = 0; + mutable quint32 m_hash = 0; }; class Q_AUTOTEST_EXPORT QHashedCStringRef @@ -169,9 +169,9 @@ private: inline void computeHash() const; - const char *m_data; - int m_length; - mutable quint32 m_hash; + const char *m_data = nullptr; + int m_length = 0; + mutable quint32 m_hash = 0; }; class QStringHashData; @@ -179,7 +179,7 @@ class Q_AUTOTEST_EXPORT QStringHashNode { public: QStringHashNode() - : length(0), hash(0), symbolId(0), ckey(nullptr) + : ckey(nullptr) { } @@ -210,9 +210,9 @@ public: QFlagPointer next; - qint32 length; - quint32 hash; - quint32 symbolId; + qint32 length = 0; + quint32 hash = 0; + quint32 symbolId = 0; union { const char *ckey; @@ -276,25 +276,20 @@ public: class Q_AUTOTEST_EXPORT QStringHashData { public: - QStringHashData() - : buckets(nullptr), numBuckets(0), size(0), numBits(0) -#ifdef QSTRINGHASH_LINK_DEBUG - , linkCount(0) -#endif - {} + QStringHashData() {} - QStringHashNode **buckets; - int numBuckets; - int size; - short numBits; + QStringHashNode **buckets = nullptr; + int numBuckets = 0; + int size = 0; + short numBits = 0; #ifdef QSTRINGHASH_LINK_DEBUG - int linkCount; + int linkCount = 0; #endif struct IteratorData { - IteratorData() : n(nullptr), p(nullptr) {} - QStringHashNode *n; - void *p; + IteratorData() {} + QStringHashNode *n = nullptr; + void *p = nullptr; }; void rehashToBits(short); void rehashToSize(int); @@ -369,10 +364,10 @@ public: }; struct ReservedNodePool { - ReservedNodePool() : count(0), used(0), nodes(nullptr) {} + ReservedNodePool() : nodes(nullptr) {} ~ReservedNodePool() { delete [] nodes; } - int count; - int used; + int count = 0; + int used = 0; Node *nodes; }; @@ -1038,7 +1033,7 @@ inline uint qHash(const QHashedStringRef &string) } QHashedString::QHashedString() -: QString(), m_hash(0) +: QString() { } @@ -1089,7 +1084,6 @@ quint32 QHashedString::existingHash() const } QHashedStringRef::QHashedStringRef() -: m_data(nullptr), m_length(0), m_hash(0) { } @@ -1236,7 +1230,6 @@ quint32 QHashedStringRef::hash() const } QHashedCStringRef::QHashedCStringRef() -: m_data(nullptr), m_length(0), m_hash(0) { } diff --git a/src/qml/qml/ftw/qintrusivelist_p.h b/src/qml/qml/ftw/qintrusivelist_p.h index c3b16f5b8c..8992be9f93 100644 --- a/src/qml/qml/ftw/qintrusivelist_p.h +++ b/src/qml/qml/ftw/qintrusivelist_p.h @@ -95,7 +95,7 @@ public: private: static inline N *nodeToN(QIntrusiveListNode *node); - QIntrusiveListNode *__first; + QIntrusiveListNode *__first = nullptr; }; class QIntrusiveListNode @@ -107,8 +107,8 @@ public: inline void remove(); inline bool isInList() const; - QIntrusiveListNode *_next; - QIntrusiveListNode**_prev; + QIntrusiveListNode *_next = nullptr; + QIntrusiveListNode**_prev = nullptr; }; template @@ -165,7 +165,7 @@ typename QIntrusiveList::iterator &QIntrusiveList::iterato template QIntrusiveList::QIntrusiveList() -: __first(nullptr) + { } @@ -245,7 +245,6 @@ N *QIntrusiveList::nodeToN(QIntrusiveListNode *node) } QIntrusiveListNode::QIntrusiveListNode() -: _next(nullptr), _prev(nullptr) { } diff --git a/src/qml/qml/ftw/qqmlnullablevalue_p.h b/src/qml/qml/ftw/qqmlnullablevalue_p.h index 7a9e4d7b8a..5b3d2fc456 100644 --- a/src/qml/qml/ftw/qqmlnullablevalue_p.h +++ b/src/qml/qml/ftw/qqmlnullablevalue_p.h @@ -57,7 +57,7 @@ template struct QQmlNullableValue { QQmlNullableValue() - : isNull(true), value(T()) {} + : value(T()) {} QQmlNullableValue(const QQmlNullableValue &o) : isNull(o.isNull), value(o.value) {} QQmlNullableValue(const T &t) @@ -70,7 +70,7 @@ struct QQmlNullableValue void invalidate() { isNull = true; } bool isValid() const { return !isNull; } - bool isNull; + bool isNull = true; T value; }; diff --git a/src/qml/qml/qqmlabstractbinding_p.h b/src/qml/qml/qqmlabstractbinding_p.h index bea2d253e4..fc53be3e7b 100644 --- a/src/qml/qml/qqmlabstractbinding_p.h +++ b/src/qml/qml/qqmlabstractbinding_p.h @@ -95,8 +95,8 @@ public: { return m_nextBinding.flag2(); } struct RefCount { - RefCount() : refCount(0) {} - int refCount; + RefCount() {} + int refCount = 0; void ref() { ++refCount; } int deref() { return --refCount; } operator int() const { return refCount; } diff --git a/src/qml/qml/qqmlboundsignalexpressionpointer_p.h b/src/qml/qml/qqmlboundsignalexpressionpointer_p.h index 685e0160a3..eabe6666b4 100644 --- a/src/qml/qml/qqmlboundsignalexpressionpointer_p.h +++ b/src/qml/qml/qqmlboundsignalexpressionpointer_p.h @@ -58,7 +58,7 @@ class QQmlBoundSignalExpression; class Q_QML_PRIVATE_EXPORT QQmlBoundSignalExpressionPointer { public: - inline QQmlBoundSignalExpressionPointer() : o(nullptr) {} + inline QQmlBoundSignalExpressionPointer() {} QQmlBoundSignalExpressionPointer(QQmlBoundSignalExpression *); QQmlBoundSignalExpressionPointer(const QQmlBoundSignalExpressionPointer &); ~QQmlBoundSignalExpressionPointer(); @@ -73,7 +73,7 @@ public: QQmlBoundSignalExpressionPointer &take(QQmlBoundSignalExpression *); private: - QQmlBoundSignalExpression *o; + QQmlBoundSignalExpression *o = nullptr; }; QT_END_NAMESPACE diff --git a/src/qml/qml/qqmldirparser_p.h b/src/qml/qml/qqmldirparser_p.h index 1530b7a6cf..95370398ad 100644 --- a/src/qml/qml/qqmldirparser_p.h +++ b/src/qml/qml/qqmldirparser_p.h @@ -91,8 +91,7 @@ public: struct Component { - Component() - : majorVersion(0), minorVersion(0), internal(false), singleton(false) {} + Component() {} Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion) : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion), @@ -100,24 +99,23 @@ public: QString typeName; QString fileName; - int majorVersion; - int minorVersion; - bool internal; - bool singleton; + int majorVersion = 0; + int minorVersion = 0; + bool internal = false; + bool singleton = false; }; struct Script { - Script() - : majorVersion(0), minorVersion(0) {} + Script() {} Script(const QString &nameSpace, const QString &fileName, int majorVersion, int minorVersion) : nameSpace(nameSpace), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) {} QString nameSpace; QString fileName; - int majorVersion; - int minorVersion; + int majorVersion = 0; + int minorVersion = 0; }; QHash components() const; diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h index 53f5dbed02..302fdd56c4 100644 --- a/src/qml/qml/qqmlglobal_p.h +++ b/src/qml/qml/qqmlglobal_p.h @@ -368,12 +368,12 @@ public: struct QQmlSourceLocation { - QQmlSourceLocation() : line(0), column(0) {} + QQmlSourceLocation() {} QQmlSourceLocation(const QString &sourceFile, quint16 line, quint16 column) : sourceFile(sourceFile), line(line), column(column) {} QString sourceFile; - quint16 line; - quint16 column; + quint16 line = 0; + quint16 column = 0; }; QT_END_NAMESPACE diff --git a/src/qml/qml/qqmlguard_p.h b/src/qml/qml/qqmlguard_p.h index 87c3677d29..808bf4c709 100644 --- a/src/qml/qml/qqmlguard_p.h +++ b/src/qml/qml/qqmlguard_p.h @@ -65,9 +65,9 @@ public: inline QQmlGuardImpl(const QQmlGuardImpl &); inline ~QQmlGuardImpl(); - QObject *o; - QQmlGuardImpl *next; - QQmlGuardImpl **prev; + QObject *o = nullptr; + QQmlGuardImpl *next = nullptr; + QQmlGuardImpl **prev = nullptr; inline void addGuard(); inline void remGuard(); @@ -113,18 +113,17 @@ Q_DECLARE_METATYPE(QQmlGuard) QT_BEGIN_NAMESPACE QQmlGuardImpl::QQmlGuardImpl() -: o(nullptr), next(nullptr), prev(nullptr) { } QQmlGuardImpl::QQmlGuardImpl(QObject *g) -: o(g), next(nullptr), prev(nullptr) +: o(g) { if (o) addGuard(); } QQmlGuardImpl::QQmlGuardImpl(const QQmlGuardImpl &g) -: o(g.o), next(nullptr), prev(nullptr) +: o(g.o) { if (o) addGuard(); } diff --git a/src/qml/qml/qqmllist.h b/src/qml/qml/qqmllist.h index 4c6ae0cb8f..90ec57c911 100644 --- a/src/qml/qml/qqmllist.h +++ b/src/qml/qml/qqmllist.h @@ -61,20 +61,15 @@ public: typedef void (*ClearFunction)(QQmlListProperty *); QQmlListProperty() - : object(nullptr), - data(nullptr), - append(nullptr), + : append(nullptr), count(nullptr), at(nullptr), - clear(nullptr), - dummy1(nullptr), - dummy2(nullptr) + clear(nullptr) {} QQmlListProperty(QObject *o, QList &list) : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), - clear(qlist_clear), - dummy1(nullptr), - dummy2(nullptr) + clear(qlist_clear) + {} QQmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c, AtFunction t, ClearFunction r ) @@ -83,18 +78,15 @@ public: append(a), count(c), at(t), - clear(r), - dummy1(nullptr), - dummy2(nullptr) + clear(r) + {} QQmlListProperty(QObject *o, void *d, CountFunction c, AtFunction t) : object(o), data(d), append(nullptr), count(c), at(t), - clear(nullptr), - dummy1(nullptr), - dummy2(nullptr) + clear(nullptr) {} bool operator==(const QQmlListProperty &o) const { return object == o.object && @@ -105,8 +97,8 @@ public: clear == o.clear; } - QObject *object; - void *data; + QObject *object = nullptr; + void *data = nullptr; AppendFunction append; @@ -115,8 +107,8 @@ public: ClearFunction clear; - void *dummy1; - void *dummy2; + void *dummy1 = nullptr; + void *dummy2 = nullptr; private: static void qlist_append(QQmlListProperty *p, T *v) { diff --git a/src/qml/qml/qqmlnotifier_p.h b/src/qml/qml/qqmlnotifier_p.h index 39761875bf..d77e314de5 100644 --- a/src/qml/qml/qqmlnotifier_p.h +++ b/src/qml/qml/qqmlnotifier_p.h @@ -73,7 +73,7 @@ private: friend class QQmlThreadNotifierProxyObject; static void emitNotify(QQmlNotifierEndpoint *, void **a); - QQmlNotifierEndpoint *endpoints; + QQmlNotifierEndpoint *endpoints = nullptr; }; class QQmlEngine; @@ -129,7 +129,6 @@ private: }; QQmlNotifier::QQmlNotifier() -: endpoints(nullptr) { } diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h index 22be6ba60c..7b04ba11b8 100644 --- a/src/qml/qml/qqmlpropertycache_p.h +++ b/src/qml/qml/qqmlpropertycache_p.h @@ -376,10 +376,10 @@ private: struct QQmlEnumValue { - QQmlEnumValue() : value(-1) {} + QQmlEnumValue() {} QQmlEnumValue(const QString &n, int v) : namedValue(n), value(v) {} QString namedValue; - int value; + int value = -1; }; struct QQmlEnumData diff --git a/src/qml/types/qqmltimer.cpp b/src/qml/types/qqmltimer.cpp index 2037c4f6cd..6554010f36 100644 --- a/src/qml/types/qqmltimer.cpp +++ b/src/qml/types/qqmltimer.cpp @@ -57,7 +57,7 @@ class QQmlTimerPrivate : public QObjectPrivate, public QAnimationJobChangeListen Q_DECLARE_PUBLIC(QQmlTimer) public: QQmlTimerPrivate() - : interval(1000), running(false), repeating(false), triggeredOnStart(false) + : running(false), repeating(false), triggeredOnStart(false) , classBegun(false), componentComplete(false), firstTick(true), awaitingTick(false) {} void animationFinished(QAbstractAnimationJob *) override; @@ -71,7 +71,7 @@ public: } } - int interval; + int interval = 1000; QPauseAnimationJob pause; bool running : 1; bool repeating : 1; diff --git a/src/qml/util/qqmlchangeset_p.h b/src/qml/util/qqmlchangeset_p.h index 8bc13f1b67..8347a3ff19 100644 --- a/src/qml/util/qqmlchangeset_p.h +++ b/src/qml/util/qqmlchangeset_p.h @@ -62,10 +62,10 @@ class Q_QML_PRIVATE_EXPORT QQmlChangeSet public: struct MoveKey { - MoveKey() : moveId(-1), offset(0) {} + MoveKey() {} MoveKey(int moveId, int offset) : moveId(moveId), offset(offset) {} - int moveId; - int offset; + int moveId = -1; + int offset = 0; }; // The storrage for Change (below). This struct is trivial, which it has to be in order to store diff --git a/src/qml/util/qqmllistcompositor_p.h b/src/qml/util/qqmllistcompositor_p.h index d5723889e1..172040559c 100644 --- a/src/qml/util/qqmllistcompositor_p.h +++ b/src/qml/util/qqmllistcompositor_p.h @@ -87,17 +87,17 @@ public: class Range { public: - Range() : next(this), previous(this), list(nullptr), index(0), count(0), flags(0) {} + Range() : next(this), previous(this) {} Range(Range *next, void *list, int index, int count, uint flags) : next(next), previous(next->previous), list(list), index(index), count(count), flags(flags) { next->previous = this; previous->next = this; } Range *next; Range *previous; - void *list; - int index; - int count; - uint flags; + void *list = nullptr; + int index = 0; + int count = 0; + uint flags = 0; inline int start() const { return index; } inline int end() const { return index + count; } @@ -145,11 +145,11 @@ public: void setGroup(Group g) { group = g; groupFlag = 1 << g; } - Range *range; - int offset; - Group group; + Range *range = nullptr; + int offset = 0; + Group group = Default; int groupFlag; - int groupCount; + int groupCount = 0; union { struct { int cacheIndex; @@ -308,8 +308,7 @@ Q_DECLARE_TYPEINFO(QQmlListCompositor::Change, Q_PRIMITIVE_TYPE); Q_DECLARE_TYPEINFO(QQmlListCompositor::Remove, Q_PRIMITIVE_TYPE); Q_DECLARE_TYPEINFO(QQmlListCompositor::Insert, Q_PRIMITIVE_TYPE); -inline QQmlListCompositor::iterator::iterator() - : range(nullptr), offset(0), group(Default), groupCount(0) {} +inline QQmlListCompositor::iterator::iterator() {} inline QQmlListCompositor::iterator::iterator(const iterator &it) : range(it.range) , offset(it.offset) -- cgit v1.2.3