From 2c871dfd38d89d6415c2c25d47b4a0e9c8b2ef11 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 22 Nov 2019 15:34:38 +0100 Subject: Avoid initializing QFlags with 0 or nullptr in further cases Amends qtbase/af2daafde72db02454d24b7d691aa6861525ab99. Where applicable, port over to member initialization, thus also fixing nullptr warnings. Change-Id: Iaaf2dbbbcf2952253390b8839fd15a1b17be32c0 Reviewed-by: Allan Sandfeld Jensen --- src/widgets/kernel/qboxlayout.cpp | 2 +- src/widgets/kernel/qformlayout.cpp | 26 +++++++++++--------------- src/widgets/kernel/qlayoutitem.cpp | 2 +- 3 files changed, 13 insertions(+), 17 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp index 76d8533271..78d37f381e 100644 --- a/src/widgets/kernel/qboxlayout.cpp +++ b/src/widgets/kernel/qboxlayout.cpp @@ -1173,7 +1173,7 @@ void QBoxLayout::setDirection(Direction direction) if (box->magic) { QSpacerItem *sp = box->item->spacerItem(); if (sp) { - if (sp->expandingDirections() == Qt::Orientations(0) /*No Direction*/) { + if (sp->expandingDirections() == Qt::Orientations{} /*No Direction*/) { //spacing or strut QSize s = sp->sizeHint(); sp->changeSize(s.height(), s.width(), diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index 1c8b997dcb..c2838083f3 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -199,18 +199,17 @@ public: ItemMatrix m_matrix; QList m_things; - int layoutWidth; // the last width that we called setupVerticalLayoutData on (for vLayouts) + int layoutWidth = -1; // the last width that we called setupVerticalLayoutData on (for vLayouts) - int hfw_width; // the last width we calculated HFW for - int hfw_height; // what that height was - int hfw_minheight; // what that minheight was + int hfw_width = -1; // the last width we calculated HFW for + int hfw_height = -1; // what that height was - int hfw_sh_height; // the hfw for sh_width - int hfw_sh_minheight; // the minhfw for sh_width + int hfw_sh_height = -1; // the hfw for sh_width + int hfw_sh_minheight = -1; // the minhfw for sh_width - int min_width; // the width that gets turned into minSize (from updateSizes) - int sh_width; // the width that gets turned into prefSize (from updateSizes) - int thresh_width; // the width that we start splitting label/field pairs at (from updateSizes) + int min_width = -1; // the width that gets turned into minSize (from updateSizes) + int sh_width = -1; // the width that gets turned into prefSize (from updateSizes) + int thresh_width = QLAYOUTSIZE_MAX; // the width that we start splitting label/field pairs at (from updateSizes) QSize minSize; QSize prefSize; int formMaxWidth; @@ -222,17 +221,15 @@ public: QVector hfwLayouts; - int hSpacing; - int vSpacing; + int hSpacing = -1; + int vSpacing = -1; QLayoutItem* replaceAt(int index, QLayoutItem*) override; }; QFormLayoutPrivate::QFormLayoutPrivate() : fieldGrowthPolicy(DefaultFieldGrowthPolicy), rowWrapPolicy(DefaultRowWrapPolicy), has_hfw(false), dirty(true), sizesDirty(true), - expandVertical(0), expandHorizontal(0), labelAlignment(0), formAlignment(0), - layoutWidth(-1), hfw_width(-1), hfw_sh_height(-1), min_width(-1), - sh_width(-1), thresh_width(QLAYOUTSIZE_MAX), hSpacing(-1), vSpacing(-1) + expandVertical(0), expandHorizontal(0) { } @@ -481,7 +478,6 @@ void QFormLayoutPrivate::recalcHFW(int w) } else { hfw_width = w; hfw_height = qMin(QLAYOUTSIZE_MAX, h); - hfw_minheight = qMin(QLAYOUTSIZE_MAX, mh); } } diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index 0aab0bb06d..ca5a89e4dc 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -591,7 +591,7 @@ Qt::Orientations QSpacerItem::expandingDirections() const Qt::Orientations QWidgetItem::expandingDirections() const { if (isEmpty()) - return Qt::Orientations(0); + return {}; Qt::Orientations e = wid->sizePolicy().expandingDirections(); /* -- cgit v1.2.3