From af2daafde72db02454d24b7d691aa6861525ab99 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 18 Nov 2019 17:01:26 +0100 Subject: Deprecate constructing QFlags from a pointer This was used to support QFlags f = 0 initialization, but with 0 used as a pointer literal now considered bad form, it had been changed many places to QFlags f = nullptr, which is meaningless and confusing. Change-Id: I4bc592151c255dc5cab1a232615caecc520f02e8 Reviewed-by: Thiago Macieira --- src/gui/util/qgridlayoutengine.cpp | 2 +- src/gui/util/qgridlayoutengine_p.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui/util') diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp index 33adac40b2..024f0f084e 100644 --- a/src/gui/util/qgridlayoutengine.cpp +++ b/src/gui/util/qgridlayoutengine.cpp @@ -1147,7 +1147,7 @@ QLayoutPolicy::ControlTypes QGridLayoutEngine::controlTypes(LayoutSide side) con Qt::Orientation orientation = (side == Top || side == Bottom) ? Qt::Vertical : Qt::Horizontal; int row = (side == Top || side == Left) ? effectiveFirstRow(orientation) : effectiveLastRow(orientation); - QLayoutPolicy::ControlTypes result = 0; + QLayoutPolicy::ControlTypes result; for (int column = columnCount(orientation) - 1; column >= 0; --column) { if (QGridLayoutItem *item = itemAt(row, column, orientation)) diff --git a/src/gui/util/qgridlayoutengine_p.h b/src/gui/util/qgridlayoutengine_p.h index 5f0e84edb1..181326103b 100644 --- a/src/gui/util/qgridlayoutengine_p.h +++ b/src/gui/util/qgridlayoutengine_p.h @@ -276,7 +276,7 @@ class Q_GUI_EXPORT QGridLayoutItem { public: QGridLayoutItem(int row, int column, int rowSpan = 1, int columnSpan = 1, - Qt::Alignment alignment = nullptr); + Qt::Alignment alignment = { }); virtual ~QGridLayoutItem() {} inline int firstRow() const { return q_firstRows[Ver]; } @@ -339,7 +339,7 @@ private: class Q_GUI_EXPORT QGridLayoutEngine { public: - QGridLayoutEngine(Qt::Alignment defaultAlignment = Qt::Alignment(nullptr), bool snapToPixelGrid = false); + QGridLayoutEngine(Qt::Alignment defaultAlignment = { }, bool snapToPixelGrid = false); inline ~QGridLayoutEngine() { qDeleteAll(q_items); } int rowCount(Qt::Orientation orientation) const; -- cgit v1.2.3 From 3359b29c99581f52acf033489ad35884a01ccac8 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Tue, 3 Dec 2019 11:13:42 +0100 Subject: QDoubleValidator: Fix thousand separator handling QDoubleValidator would accept "1,23" as valid in a locale which has ',' as a thousand separator. However, it should have been Intermediate instead, as there is still one digit missing. Fixes: QTBUG-75110 Change-Id: I6de90f0b6f1eae95dc8dfc8e5f9658e482e46db3 Reviewed-by: Ulf Hermann Reviewed-by: Edward Welbourne --- src/gui/util/qvalidator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/util') diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index 2237b016e9..54cbb28ffa 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -688,7 +688,7 @@ QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QL return QValidator::Invalid; bool ok = false; - double i = buff.toDouble(&ok); // returns 0.0 if !ok + double i = locale.toDouble(input, &ok); // returns 0.0 if !ok if (i == qt_qnan()) return QValidator::Invalid; if (!ok) -- cgit v1.2.3 From d872719bf543a60108db88632d061e343e12b607 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 26 Nov 2018 10:18:24 +0100 Subject: Don't use QHash::unite to merge hashes QHash::unite can silently turn a regular QHash into a multi hash, something that is not intended here. Use a regular insert() instead. Change-Id: I9244a8553e84eed5367939019347b51491765ea0 Reviewed-by: Laszlo Agocs --- src/gui/util/qshadergraphloader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/util') diff --git a/src/gui/util/qshadergraphloader.cpp b/src/gui/util/qshadergraphloader.cpp index a393e876e0..26848020f2 100644 --- a/src/gui/util/qshadergraphloader.cpp +++ b/src/gui/util/qshadergraphloader.cpp @@ -136,7 +136,7 @@ void QShaderGraphLoader::load() if (prototypesValue.isObject()) { QShaderNodesLoader loader; loader.load(prototypesValue.toObject()); - m_prototypes.unite(loader.nodes()); + m_prototypes.insert(loader.nodes()); } else { qWarning() << "Invalid prototypes property, should be an object"; m_status = Error; -- cgit v1.2.3 From ece0c0a5e7e0b18beb58ccd868bde54c7be64f78 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 22 Nov 2019 14:46:58 +0100 Subject: Tidy nullptr usage Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/gui/util/qdesktopservices.cpp | 2 +- src/gui/util/qgridlayoutengine.cpp | 26 +++++++++++++------------- src/gui/util/qtexturefiledata.cpp | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src/gui/util') diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index 99214c4960..763f309fc7 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -287,7 +287,7 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c */ void QDesktopServices::unsetUrlHandler(const QString &scheme) { - setUrlHandler(scheme, 0, 0); + setUrlHandler(scheme, nullptr, nullptr); } #if QT_DEPRECATED_SINCE(5, 0) diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp index 024f0f084e..4af5e47f8f 100644 --- a/src/gui/util/qgridlayoutengine.cpp +++ b/src/gui/util/qgridlayoutengine.cpp @@ -177,7 +177,7 @@ void QGridLayoutRowData::distributeMultiCells(const QGridLayoutRowInfo &rowInfo, qreal extra = compare(box, totalBox, j); if (extra > 0.0) { calculateGeometries(start, end, box.q_sizes(j), dummy.data(), newSizes.data(), - 0, totalBox, rowInfo, snapToPixelGrid); + nullptr, totalBox, rowInfo, snapToPixelGrid); for (int k = 0; k < span; ++k) extras[k].q_sizes(j) = newSizes[k]; @@ -988,7 +988,7 @@ void QGridLayoutEngine::removeItem(QGridLayoutItem *item) for (int i = item->firstRow(); i <= item->lastRow(); ++i) { for (int j = item->firstColumn(); j <= item->lastColumn(); ++j) { if (itemAt(i, j) == item) - setItemAt(i, j, 0); + setItemAt(i, j, nullptr); } } @@ -1001,7 +1001,7 @@ QGridLayoutItem *QGridLayoutEngine::itemAt(int row, int column, Qt::Orientation if (orientation == Qt::Horizontal) qSwap(row, column); if (uint(row) >= uint(rowCount()) || uint(column) >= uint(columnCount())) - return 0; + return nullptr; return q_grid.at((row * internalGridColumnCount()) + column); } @@ -1100,7 +1100,7 @@ QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint, if (constraintOrientation() == Qt::Vertical) { //We have items whose height depends on their width if (constraint.width() >= 0) { - ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo); + ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], nullptr, nullptr, Qt::Horizontal, styleInfo); QVector sizehint_xx; QVector sizehint_widths; @@ -1110,14 +1110,14 @@ QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint, //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as //constraints to find the row heights q_columnData.calculateGeometries(0, columnCount(), width, sizehint_xx.data(), sizehint_widths.data(), - 0, sizehint_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); + nullptr, sizehint_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], sizehint_xx.data(), sizehint_widths.data(), Qt::Vertical, styleInfo); sizeHintCalculated = true; } } else { if (constraint.height() >= 0) { //We have items whose width depends on their height - ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo); + ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], nullptr, nullptr, Qt::Vertical, styleInfo); QVector sizehint_yy; QVector sizehint_heights; @@ -1127,7 +1127,7 @@ QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint, //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as //constraints to find the column widths q_rowData.calculateGeometries(0, rowCount(), height, sizehint_yy.data(), sizehint_heights.data(), - 0, sizehint_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); + nullptr, sizehint_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], sizehint_yy.data(), sizehint_heights.data(), Qt::Horizontal, styleInfo); sizeHintCalculated = true; } @@ -1137,8 +1137,8 @@ QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint, } //No items with height for width, so it doesn't matter which order we do these in - ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo); - ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo); + ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], nullptr, nullptr, Qt::Horizontal, styleInfo); + ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], nullptr, nullptr, Qt::Vertical, styleInfo); return QSizeF(q_totalBoxes[Hor].q_sizes(which), q_totalBoxes[Ver].q_sizes(which)); } @@ -1650,18 +1650,18 @@ void QGridLayoutEngine::ensureGeometries(const QSizeF &size, if (constraintOrientation() != Qt::Horizontal) { //We might have items whose height depends on their width (HFW) - ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo); + ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], nullptr, nullptr, Qt::Horizontal, styleInfo); //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as //constraints to find the row heights q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), - 0, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); + nullptr, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], q_xx.data(), q_widths.data(), Qt::Vertical, styleInfo); //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), q_descents.data(), q_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); } else { //We have items whose width depends on their height (WFH) - ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo); + ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], nullptr, nullptr, Qt::Vertical, styleInfo); //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as //constraints to find the column widths q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), @@ -1669,7 +1669,7 @@ void QGridLayoutEngine::ensureGeometries(const QSizeF &size, ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], q_yy.data(), q_heights.data(), Qt::Horizontal, styleInfo); //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), - 0, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); + nullptr, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); } } diff --git a/src/gui/util/qtexturefiledata.cpp b/src/gui/util/qtexturefiledata.cpp index ebf46f8e4e..41cbd1b15a 100644 --- a/src/gui/util/qtexturefiledata.cpp +++ b/src/gui/util/qtexturefiledata.cpp @@ -247,7 +247,7 @@ void QTextureFileData::setLogName(const QByteArray &name) static QByteArray glFormatName(quint32 fmt) { - const char *id = 0; + const char *id = nullptr; #if QT_CONFIG(opengl) id = QMetaEnum::fromType().valueToKey(fmt); #endif -- cgit v1.2.3 From d6266c757d2f2ea4ff1e71dc8545f9bf97aa3bb1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 6 Dec 2019 13:19:37 +0100 Subject: Replace usages of QVariant::value by qvariant_cast This is done automatically with a clazy check Change-Id: I3b59511d3d36d416c8eda74858ead611d327b116 Reviewed-by: Lars Knoll --- src/gui/util/qshadergenerator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui/util') diff --git a/src/gui/util/qshadergenerator.cpp b/src/gui/util/qshadergenerator.cpp index bcb985de54..4beed8ed25 100644 --- a/src/gui/util/qshadergenerator.cpp +++ b/src/gui/util/qshadergenerator.cpp @@ -273,11 +273,11 @@ namespace const QByteArray placeholder = QByteArray(QByteArrayLiteral("$") + parameterName.toUtf8()); const QVariant parameter = node.parameter(parameterName); if (parameter.userType() == qMetaTypeId()) { - const QShaderLanguage::StorageQualifier qualifier = parameter.value(); + const QShaderLanguage::StorageQualifier qualifier = qvariant_cast(parameter); const QByteArray value = toGlsl(qualifier, format); result.replace(placeholder, value); } else if (parameter.userType() == qMetaTypeId()) { - const QShaderLanguage::VariableType type = parameter.value(); + const QShaderLanguage::VariableType type = qvariant_cast(parameter); const QByteArray value = toGlsl(type); result.replace(placeholder, value); } else { -- cgit v1.2.3 From d593c5865acb544d02e45ac24245d9bc9988ffb1 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Thu, 12 Dec 2019 14:06:31 +0100 Subject: Remove QOpenGLTexture dependency from QTextureFileData Just print the hex value of the format. Task-number: QTBUG-74409 Change-Id: I0441eda050735325f7686532b17ef765f71bec9b Reviewed-by: Paul Olav Tvete --- src/gui/util/qtexturefiledata.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src/gui/util') diff --git a/src/gui/util/qtexturefiledata.cpp b/src/gui/util/qtexturefiledata.cpp index 41cbd1b15a..3c8130c229 100644 --- a/src/gui/util/qtexturefiledata.cpp +++ b/src/gui/util/qtexturefiledata.cpp @@ -38,11 +38,7 @@ ****************************************************************************/ #include "qtexturefiledata_p.h" -#include #include -#if QT_CONFIG(opengl) -#include -#endif QT_BEGIN_NAMESPACE @@ -247,13 +243,7 @@ void QTextureFileData::setLogName(const QByteArray &name) static QByteArray glFormatName(quint32 fmt) { - const char *id = nullptr; -#if QT_CONFIG(opengl) - id = QMetaEnum::fromType().valueToKey(fmt); -#endif - QByteArray res(id ? id : "(?)"); - res += " [0x" + QByteArray::number(fmt, 16).rightJustified(4, '0') + ']'; - return res; + return QByteArray("0x" + QByteArray::number(fmt, 16).rightJustified(4, '0')); } QDebug operator<<(QDebug dbg, const QTextureFileData &d) -- cgit v1.2.3