From 744e77b841878fb017c0f2d60607090008f28180 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 21 Nov 2019 13:10:02 +0100 Subject: Avoid initializing QFlags with 0 or nullptr It is being deprecated. Change-Id: I844bd92af85bc53a8fc0371408d05277bd49f511 Reviewed-by: Simon Hausmann Reviewed-by: Laszlo Agocs Reviewed-by: Ulf Hermann --- src/imports/folderlistmodel/qquickfolderlistmodel.cpp | 2 +- src/imports/layouts/qquickgridlayoutengine_p.h | 2 +- src/imports/layouts/qquicklinearlayout.cpp | 4 ++-- src/plugins/scenegraph/d3d12/qsgd3d12engine_p.h | 4 ++-- src/qml/qml/qqmlproperty.cpp | 4 ++-- src/qml/qml/qqmlproperty_p.h | 4 ++-- src/qmlmodels/qqmldelegatemodel.cpp | 2 +- src/quick/items/qquickevents_p_p.h | 5 ++--- src/quick/items/qquickgenericshadereffect.cpp | 1 - src/quick/items/qquickitem.cpp | 2 +- src/quick/items/qquickitem_p.h | 4 ++-- src/quick/items/qquickwindow_p.h | 4 ++-- src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 2 +- src/quick/scenegraph/coreapi/qsgmaterial.cpp | 1 - src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp | 4 ++-- src/quick/scenegraph/coreapi/qsgnode.cpp | 3 --- src/quick/scenegraph/coreapi/qsgnode.h | 2 +- src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp | 2 +- src/quick/scenegraph/qsgcontextplugin.cpp | 1 - src/quick/scenegraph/qsgrenderloop.cpp | 2 +- src/quick/scenegraph/qsgrhilayer.cpp | 2 +- src/quick/scenegraph/qsgrhisupport.cpp | 2 +- src/quick/scenegraph/qsgthreadedrenderloop.cpp | 2 +- src/quick/scenegraph/util/qsgplaintexture.cpp | 4 ++-- 24 files changed, 29 insertions(+), 36 deletions(-) diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp index f5acfd86b7..26c6d4032f 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp @@ -107,7 +107,7 @@ void QQuickFolderListModelPrivate::updateSorting() { Q_Q(QQuickFolderListModel); - QDir::SortFlags flags = nullptr; + QDir::SortFlags flags; switch (sortField) { case QQuickFolderListModel::Unsorted: diff --git a/src/imports/layouts/qquickgridlayoutengine_p.h b/src/imports/layouts/qquickgridlayoutengine_p.h index 2810e2e5d0..c53be89477 100644 --- a/src/imports/layouts/qquickgridlayoutengine_p.h +++ b/src/imports/layouts/qquickgridlayoutengine_p.h @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE class QQuickGridLayoutItem : public QGridLayoutItem { public: QQuickGridLayoutItem(QQuickItem *item, int row, int column, - int rowSpan = 1, int columnSpan = 1, Qt::Alignment alignment = 0) + int rowSpan = 1, int columnSpan = 1, Qt::Alignment alignment = { }) : QGridLayoutItem(row, column, rowSpan, columnSpan, alignment), m_item(item), sizeHintCacheDirty(true), useFallbackToWidthOrHeight(true) {} diff --git a/src/imports/layouts/qquicklinearlayout.cpp b/src/imports/layouts/qquicklinearlayout.cpp index c8d2ac5eb2..d89e575372 100644 --- a/src/imports/layouts/qquicklinearlayout.cpp +++ b/src/imports/layouts/qquicklinearlayout.cpp @@ -665,7 +665,7 @@ void QQuickGridLayout::insertLayoutItems() if (shouldIgnoreItem(child, info, sizeHints)) continue; - Qt::Alignment alignment = nullptr; + Qt::Alignment alignment; int row = -1; int column = -1; int span[2] = {1,1}; @@ -854,7 +854,7 @@ void QQuickLinearLayout::insertLayoutItems() if (shouldIgnoreItem(child, info, sizeHints)) continue; - Qt::Alignment alignment = nullptr; + Qt::Alignment alignment; if (info) alignment = info->alignment(); diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12engine_p.h b/src/plugins/scenegraph/d3d12/qsgd3d12engine_p.h index b30994fe0d..b80de28bed 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12engine_p.h +++ b/src/plugins/scenegraph/d3d12/qsgd3d12engine_p.h @@ -363,8 +363,8 @@ public: uint genTexture(); void createTexture(uint id, const QSize &size, QImage::Format format, TextureCreateFlags flags); void queueTextureResize(uint id, const QSize &size); - void queueTextureUpload(uint id, const QImage &image, const QPoint &dstPos = QPoint(), TextureUploadFlags flags = 0); - void queueTextureUpload(uint id, const QVector &images, const QVector &dstPos, TextureUploadFlags flags = 0); + void queueTextureUpload(uint id, const QImage &image, const QPoint &dstPos = QPoint(), TextureUploadFlags flags = { }); + void queueTextureUpload(uint id, const QVector &images, const QVector &dstPos, TextureUploadFlags flags = { }); void releaseTexture(uint id); void useTexture(uint id); diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 27667de678..871bec1c17 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -785,7 +785,7 @@ static void removeOldBinding(QObject *object, QQmlPropertyIndex index, QQmlPrope return; if (!(flags & QQmlPropertyPrivate::DontEnable)) - oldBinding->setEnabled(false, nullptr); + oldBinding->setEnabled(false, {}); oldBinding->removeFromObject(); } @@ -1451,7 +1451,7 @@ QQmlMetaObject QQmlPropertyPrivate::rawMetaObjectForType(QQmlEnginePrivate *engi */ bool QQmlProperty::write(const QVariant &value) const { - return QQmlPropertyPrivate::write(*this, value, nullptr); + return QQmlPropertyPrivate::write(*this, value, {}); } /*! diff --git a/src/qml/qml/qqmlproperty_p.h b/src/qml/qml/qqmlproperty_p.h index 285c34d7fa..8abd83d7b4 100644 --- a/src/qml/qml/qqmlproperty_p.h +++ b/src/qml/qml/qqmlproperty_p.h @@ -107,9 +107,9 @@ public: static bool writeValueProperty(QObject *, const QQmlPropertyData &, const QQmlPropertyData &valueTypeData, const QVariant &, QQmlContextData *, - QQmlPropertyData::WriteFlags flags = nullptr); + QQmlPropertyData::WriteFlags flags = {}); static bool write(QObject *, const QQmlPropertyData &, const QVariant &, - QQmlContextData *, QQmlPropertyData::WriteFlags flags = nullptr); + QQmlContextData *, QQmlPropertyData::WriteFlags flags = {}); static void findAliasTarget(QObject *, QQmlPropertyIndex, QObject **, QQmlPropertyIndex *); enum BindingFlag { diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp index 47cbe427e7..531ba18a4b 100644 --- a/src/qmlmodels/qqmldelegatemodel.cpp +++ b/src/qmlmodels/qqmldelegatemodel.cpp @@ -3453,7 +3453,7 @@ QObject *QQmlPartsModel::object(int index, QQmlIncubator::IncubationMode incubat QQmlInstanceModel::ReleaseFlags QQmlPartsModel::release(QObject *item) { - QQmlInstanceModel::ReleaseFlags flags = nullptr; + QQmlInstanceModel::ReleaseFlags flags; QHash::iterator it = m_packaged.find(item); if (it != m_packaged.end()) { diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h index 5acf98d471..338db5d66e 100644 --- a/src/quick/items/qquickevents_p_p.h +++ b/src/quick/items/qquickevents_p_p.h @@ -90,7 +90,7 @@ class QQuickKeyEvent : public QObject public: QQuickKeyEvent() - : event(QEvent::None, 0, nullptr) + : event(QEvent::None, 0, { }) {} void reset(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, @@ -144,12 +144,11 @@ public: QQuickMouseEvent() : _buttons(Qt::NoButton), _modifiers(Qt::NoModifier) , _wasHeld(false), _isClick(false), _accepted(false) - , _flags(Qt::MouseEventFlags(nullptr)) {} void reset(qreal x, qreal y, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, bool isClick = false, bool wasHeld = false, - Qt::MouseEventFlags flags = nullptr) + Qt::MouseEventFlags flags = { }) { _x = x; _y = y; diff --git a/src/quick/items/qquickgenericshadereffect.cpp b/src/quick/items/qquickgenericshadereffect.cpp index df61ee853d..f42b7e6580 100644 --- a/src/quick/items/qquickgenericshadereffect.cpp +++ b/src/quick/items/qquickgenericshadereffect.cpp @@ -78,7 +78,6 @@ QQuickGenericShaderEffect::QQuickGenericShaderEffect(QQuickShaderEffect *item, Q , m_mgr(nullptr) , m_fragNeedsUpdate(true) , m_vertNeedsUpdate(true) - , m_dirty(nullptr) { qRegisterMetaType("ShaderInfo::Type"); for (int i = 0; i < NShader; ++i) diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 3785abc450..8454010ee9 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -8812,7 +8812,7 @@ QQuickItemPrivate::ExtraData::ExtraData() effectRefCount(0), hideRefCount(0), recursiveEffectRefCount(0), opacityNode(nullptr), clipNode(nullptr), rootNode(nullptr), - acceptedMouseButtons(nullptr), origin(QQuickItem::Center), + origin(QQuickItem::Center), transparentForPositioner(false) { } diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index 7c3325fd90..bc0d04c763 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -336,7 +336,7 @@ public: struct ChangeListener { using ChangeTypes = QQuickItemPrivate::ChangeTypes; - ChangeListener(QQuickItemChangeListener *l = nullptr, ChangeTypes t = nullptr) + ChangeListener(QQuickItemChangeListener *l = nullptr, ChangeTypes t = { }) : listener(l) , types(t) , gTypes(QQuickGeometryChange::All) @@ -937,7 +937,7 @@ private: Qt::MouseButtons QQuickItemPrivate::acceptedMouseButtons() const { return ((extra.flag() ? Qt::LeftButton : Qt::MouseButton(0)) | - (extra.isAllocated() ? extra->acceptedMouseButtons : Qt::MouseButtons(nullptr))); + (extra.isAllocated() ? extra->acceptedMouseButtons : Qt::MouseButtons{})); } QSGContext *QQuickItemPrivate::sceneGraphContext() const diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h index af7d65dac5..d104085eb0 100644 --- a/src/quick/items/qquickwindow_p.h +++ b/src/quick/items/qquickwindow_p.h @@ -206,8 +206,8 @@ public: }; Q_DECLARE_FLAGS(FocusOptions, FocusOption) - void setFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason, FocusOptions = nullptr); - void clearFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason, FocusOptions = nullptr); + void setFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason, FocusOptions = { }); + void clearFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason, FocusOptions = { }); static void notifyFocusChangesRecur(QQuickItem **item, int remaining); void clearFocusObject() override; diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 34027cbac7..a5f4a7e2ca 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -3257,7 +3257,7 @@ bool Renderer::ensurePipelineState(Element *e, const ShaderManager::Shader *sms) ps->setShaderResourceBindings(e->srb); ps->setRenderPassDescriptor(renderPassDescriptor()); - QRhiGraphicsPipeline::Flags flags = 0; + QRhiGraphicsPipeline::Flags flags; if (needsBlendConstant(m_gstate.srcColor) || needsBlendConstant(m_gstate.dstColor)) flags |= QRhiGraphicsPipeline::UsesBlendConstants; if (m_gstate.usesScissor) diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.cpp b/src/quick/scenegraph/coreapi/qsgmaterial.cpp index c8ae26311b..087c3c4cbf 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterial.cpp +++ b/src/quick/scenegraph/coreapi/qsgmaterial.cpp @@ -153,7 +153,6 @@ static void qt_print_material_count() */ QSGMaterial::QSGMaterial() - : m_flags(nullptr) { Q_UNUSED(m_reserved); #ifndef QT_NO_DEBUG diff --git a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp index 77593591bd..c5cbd0c979 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp +++ b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp @@ -97,14 +97,14 @@ static inline QRhiShaderResourceBinding::StageFlags toSrbStage(QShader::Stage st Q_UNREACHABLE(); break; } - return 0; + return { }; } void QSGMaterialRhiShaderPrivate::prepare(QShader::Variant vertexShaderVariant) { ubufBinding = -1; ubufSize = 0; - ubufStages = 0; + ubufStages = { }; memset(combinedImageSamplerBindings, 0, sizeof(combinedImageSamplerBindings)); vertexShader = fragmentShader = nullptr; masterUniformData.clear(); diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp index 1976538aec..e07f89a6d1 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.cpp +++ b/src/quick/scenegraph/coreapi/qsgnode.cpp @@ -245,7 +245,6 @@ static void qt_print_node_count() */ QSGNode::QSGNode() : m_nodeFlags(OwnedByParent) - , m_dirtyState(nullptr) { init(); } @@ -264,7 +263,6 @@ QSGNode::QSGNode(NodeType type) , m_previousSibling(nullptr) , m_subtreeRenderableCount(type == GeometryNodeType || type == RenderNodeType ? 1 : 0) , m_nodeFlags(OwnedByParent) - , m_dirtyState(nullptr) { init(); } @@ -283,7 +281,6 @@ QSGNode::QSGNode(QSGNodePrivate &dd, NodeType type) , m_previousSibling(nullptr) , m_subtreeRenderableCount(type == GeometryNodeType || type == RenderNodeType ? 1 : 0) , m_nodeFlags(OwnedByParent) - , m_dirtyState(nullptr) , d_ptr(&dd) { init(); diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h index cb677de030..5a7faed5e0 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.h +++ b/src/quick/scenegraph/coreapi/qsgnode.h @@ -146,7 +146,7 @@ public: QT_DEPRECATED void clearDirty() { } void markDirty(DirtyState bits); - QT_DEPRECATED DirtyState dirtyState() const { return nullptr; } + QT_DEPRECATED DirtyState dirtyState() const { return { }; } virtual bool isSubtreeBlocked() const; diff --git a/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp b/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp index 38d4c4440f..a0131a3f67 100644 --- a/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp +++ b/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp @@ -400,7 +400,7 @@ void RhiVisualizer::ChangeVis::gather(Node *n) // This is because many changes don't propegate their dirty state to the // parent so the node updater will not unset these states. They are // not used for anything so, unsetting it should have no side effects. - n->dirtyState = nullptr; + n->dirtyState = { }; } SHADOWNODE_TRAVERSE(n) { diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp index 66add51c55..7dfb8488ae 100644 --- a/src/quick/scenegraph/qsgcontextplugin.cpp +++ b/src/quick/scenegraph/qsgcontextplugin.cpp @@ -87,7 +87,6 @@ struct QSGAdaptationBackendData }; QSGAdaptationBackendData::QSGAdaptationBackendData() - : flags(nullptr) { // Fill in the table with the built-in adaptations. builtIns.append(new QSGSoftwareAdaptation); diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index f609055677..da6e524623 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -747,7 +747,7 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) const bool needsPresent = alsoSwap && window->isVisible(); if (cd->swapchain) { - QRhi::EndFrameFlags flags = 0; + QRhi::EndFrameFlags flags; if (!needsPresent) flags |= QRhi::SkipPresent; QRhi::FrameOpResult frameResult = rhi->endFrame(cd->swapchain, flags); diff --git a/src/quick/scenegraph/qsgrhilayer.cpp b/src/quick/scenegraph/qsgrhilayer.cpp index 757410eded..952279a3ff 100644 --- a/src/quick/scenegraph/qsgrhilayer.cpp +++ b/src/quick/scenegraph/qsgrhilayer.cpp @@ -388,7 +388,7 @@ void QSGRhiLayer::grab() m_mirrorHorizontal ? -m_rect.width() : m_rect.width(), m_mirrorVertical ? m_rect.height() : -m_rect.height()); } - QSGAbstractRenderer::MatrixTransformFlags matrixFlags = 0; + QSGAbstractRenderer::MatrixTransformFlags matrixFlags; if (!m_rhi->isYUpInNDC()) matrixFlags |= QSGAbstractRenderer::MatrixTransformFlipY; m_renderer->setProjectionMatrixToRect(mirrored, matrixFlags); diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index 12c6742342..34325a35f3 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -465,7 +465,7 @@ QRhi *QSGRhiSupport::createRhi(QWindow *window, QOffscreenSurface *offscreenSurf { QRhi *rhi = nullptr; - QRhi::Flags flags = 0; + QRhi::Flags flags; if (isProfilingRequested()) flags |= QRhi::EnableProfiling | QRhi::EnableDebugMarkers; if (isSoftwareRendererRequested()) diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index dc1f97de54..c27ec5a263 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -824,7 +824,7 @@ void QSGRenderThread::syncAndRender(QImage *grabImage) } if (cd->swapchain) { - QRhi::EndFrameFlags flags = 0; + QRhi::EndFrameFlags flags; if (grabImage) flags |= QRhi::SkipPresent; QRhi::FrameOpResult frameResult = rhi->endFrame(cd->swapchain, flags); diff --git a/src/quick/scenegraph/util/qsgplaintexture.cpp b/src/quick/scenegraph/util/qsgplaintexture.cpp index fdebe03494..0361a941db 100644 --- a/src/quick/scenegraph/util/qsgplaintexture.cpp +++ b/src/quick/scenegraph/util/qsgplaintexture.cpp @@ -281,7 +281,7 @@ void QSGPlainTexture::setTextureFromNativeObject(QRhi *rhi, QQuickWindow::Native { Q_UNUSED(type); - QRhiTexture::Flags flags = 0; + QRhiTexture::Flags flags; if (mipmap) flags |= QRhiTexture::MipMapped | QRhiTexture::UsedWithGenerateMips; @@ -421,7 +421,7 @@ void QSGPlainTexturePrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch } if (!q->m_texture) { - QRhiTexture::Flags f = 0; + QRhiTexture::Flags f; if (hasMipMaps) f |= QRhiTexture::MipMapped | QRhiTexture::UsedWithGenerateMips; -- cgit v1.2.3