From 090ea5502eac39565e33b3882f2173dd5eae473d Mon Sep 17 00:00:00 2001 From: Mike Krus Date: Fri, 20 Nov 2020 17:26:26 +0000 Subject: Enable compiling non-QML API against Qt 5.15 Built with QtQuick disabled. - C++17 required - minor issues with QList vs QVector - QMutexLocker templated vs not - moc forward declaration handling Change-Id: I5540625e74e2c009e528f56203e4b88be8d54599 Reviewed-by: Paul Lemire --- src/animation/backend/animationclip.cpp | 2 +- src/core/qscene.cpp | 5 +++++ src/core/resources/qresourcemanager_p.h | 4 ++++ src/input/backend/actioninput.cpp | 1 - src/input/backend/axissetting.cpp | 1 - src/input/frontend/qkeyboardhandler.h | 2 ++ src/plugins/renderers/opengl/opengl.pri | 2 ++ src/plugins/renderers/opengl/renderer/frameprofiler_p.h | 4 ++-- src/render/framegraph/qframegraphnode.cpp | 11 ++++++++--- src/render/materialsystem/qparameter.cpp | 2 ++ src/render/render.pro | 1 + 11 files changed, 27 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/animation/backend/animationclip.cpp b/src/animation/backend/animationclip.cpp index 699d4dc50..93a70eadd 100644 --- a/src/animation/backend/animationclip.cpp +++ b/src/animation/backend/animationclip.cpp @@ -354,7 +354,7 @@ void AnimationClip::clearData() float AnimationClip::findDuration() { // Iterate over the contained fcurves and find the longest one - double tMax = 0.0; + float tMax = 0.f; for (const Channel &channel : qAsConst(m_channels)) { for (const ChannelComponent &channelComponent : qAsConst(channel.channelComponents)) { const float t = channelComponent.fcurve.endTime(); diff --git a/src/core/qscene.cpp b/src/core/qscene.cpp index 475f63214..3381dfbe7 100644 --- a/src/core/qscene.cpp +++ b/src/core/qscene.cpp @@ -123,7 +123,12 @@ QList QScene::lookupNodes(const QList &ids) const { Q_D(const QScene); QReadLocker lock(&d->m_lock); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QList nodes(ids.size()); +#else + QList nodes; + nodes.reserve(ids.size()); +#endif int index = 0; for (QNodeId id : ids) nodes[index++] = d->m_nodeLookupTable.value(id); diff --git a/src/core/resources/qresourcemanager_p.h b/src/core/resources/qresourcemanager_p.h index 954f7b5e4..32d8d081c 100644 --- a/src/core/resources/qresourcemanager_p.h +++ b/src/core/resources/qresourcemanager_p.h @@ -165,7 +165,11 @@ public : } private: +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QMutexLocker m_locker; +#else + QMutexLocker m_locker; +#endif }; private: diff --git a/src/input/backend/actioninput.cpp b/src/input/backend/actioninput.cpp index 805fde1cf..ed8708949 100644 --- a/src/input/backend/actioninput.cpp +++ b/src/input/backend/actioninput.cpp @@ -53,7 +53,6 @@ namespace Input { ActionInput::ActionInput() : AbstractActionInput() - , m_buttons(0) { } diff --git a/src/input/backend/axissetting.cpp b/src/input/backend/axissetting.cpp index 53e645c4d..c640cd35a 100644 --- a/src/input/backend/axissetting.cpp +++ b/src/input/backend/axissetting.cpp @@ -51,7 +51,6 @@ namespace Input { AxisSetting::AxisSetting() : BackendNode() , m_deadZoneRadius(0.0f) - , m_axes(0) , m_smooth(false) { } diff --git a/src/input/frontend/qkeyboardhandler.h b/src/input/frontend/qkeyboardhandler.h index 6dac60c37..ba6119bc0 100644 --- a/src/input/frontend/qkeyboardhandler.h +++ b/src/input/frontend/qkeyboardhandler.h @@ -56,7 +56,9 @@ class Q_3DINPUTSHARED_EXPORT QKeyboardHandler : public Qt3DCore::QComponent Q_OBJECT Q_PROPERTY(Qt3DInput::QKeyboardDevice *sourceDevice READ sourceDevice WRITE setSourceDevice NOTIFY sourceDeviceChanged) Q_PROPERTY(bool focus READ focus WRITE setFocus NOTIFY focusChanged) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) Q_MOC_INCLUDE("Qt3DInput/qkeyboarddevice.h") +#endif public: explicit QKeyboardHandler(QNode *parent = nullptr); ~QKeyboardHandler(); diff --git a/src/plugins/renderers/opengl/opengl.pri b/src/plugins/renderers/opengl/opengl.pri index 37da69a1f..4308992e5 100644 --- a/src/plugins/renderers/opengl/opengl.pri +++ b/src/plugins/renderers/opengl/opengl.pri @@ -1,5 +1,7 @@ QT += core-private gui-private 3dcore 3dcore-private 3drender 3drender-private opengl-private +CONFIG += c++17 + # Qt3D is free of Q_FOREACH - make sure it stays that way: DEFINES += QT_NO_FOREACH DEFINES += BUILD_QT3D_MODULE diff --git a/src/plugins/renderers/opengl/renderer/frameprofiler_p.h b/src/plugins/renderers/opengl/renderer/frameprofiler_p.h index e94de299f..6a8f884d0 100644 --- a/src/plugins/renderers/opengl/renderer/frameprofiler_p.h +++ b/src/plugins/renderers/opengl/renderer/frameprofiler_p.h @@ -141,8 +141,8 @@ public: { #ifdef QT3D_SUPPORTS_GL_MONITOR if (m_monitor.isResultAvailable()) { - const QList samples = m_monitor.waitForSamples(); - Q_ASSERT(samples.count() >= 2 * m_recordings.count()); + const auto &samples = m_monitor.waitForSamples(); + Q_ASSERT(samples.size() >= 2 * m_recordings.size()); Qt3DCore::QSystemInformationServicePrivate *dservice = Qt3DCore::QSystemInformationServicePrivate::get(m_service); diff --git a/src/render/framegraph/qframegraphnode.cpp b/src/render/framegraph/qframegraphnode.cpp index 53b362f01..2a2bda3f2 100644 --- a/src/render/framegraph/qframegraphnode.cpp +++ b/src/render/framegraph/qframegraphnode.cpp @@ -379,15 +379,20 @@ QList QFrameGraphNodePrivate::childFrameGraphNodes() const Q_Q(const QFrameGraphNode); QList result; QQueue queue; - queue.append(q->childNodes().toList()); + const auto childNodes = q->childNodes(); + for (auto c: childNodes) + queue.append(c); result.reserve(queue.size()); while (!queue.isEmpty()) { auto *child = queue.dequeue(); auto *childFGNode = qobject_cast(child); if (childFGNode != nullptr) result.push_back(childFGNode); - else - queue.append(child->childNodes().toList()); + else { + const auto childNodes = child->childNodes(); + for (auto c: childNodes) + queue.append(c); + } } return result; } diff --git a/src/render/materialsystem/qparameter.cpp b/src/render/materialsystem/qparameter.cpp index d4a457115..2ce0d172c 100644 --- a/src/render/materialsystem/qparameter.cpp +++ b/src/render/materialsystem/qparameter.cpp @@ -41,8 +41,10 @@ #include "qparameter_p.h" #include #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #include #include +#endif /*! \qmltype Parameter diff --git a/src/render/render.pro b/src/render/render.pro index c497ff551..353f95778 100644 --- a/src/render/render.pro +++ b/src/render/render.pro @@ -4,6 +4,7 @@ MODULE = 3drender QT = core-private 3dcore-private opengl QT_FOR_PRIVATE = concurrent DEFINES += BUILD_QT3D_MODULE +CONFIG += c++17 include (backend/render-backend.pri) include (geometry/geometry.pri) -- cgit v1.2.3