diff options
author | Mike Krus <mike.krus@kdab.com> | 2020-11-20 17:26:26 +0000 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2021-01-05 16:03:03 +0000 |
commit | 090ea5502eac39565e33b3882f2173dd5eae473d (patch) | |
tree | e79db00cd7cc50e83bbce5adc06ddda59aa30224 | |
parent | 173be1a93699c54d9680d809ca5a56ce0ccccd9a (diff) |
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 <paul.lemire@kdab.com>
-rw-r--r-- | examples/qt3d/3d-text/main.cpp | 4 | ||||
-rw-r--r-- | src/animation/backend/animationclip.cpp | 2 | ||||
-rw-r--r-- | src/core/qscene.cpp | 5 | ||||
-rw-r--r-- | src/core/resources/qresourcemanager_p.h | 4 | ||||
-rw-r--r-- | src/input/backend/actioninput.cpp | 1 | ||||
-rw-r--r-- | src/input/backend/axissetting.cpp | 1 | ||||
-rw-r--r-- | src/input/frontend/qkeyboardhandler.h | 2 | ||||
-rw-r--r-- | src/plugins/renderers/opengl/opengl.pri | 2 | ||||
-rw-r--r-- | src/plugins/renderers/opengl/renderer/frameprofiler_p.h | 4 | ||||
-rw-r--r-- | src/render/framegraph/qframegraphnode.cpp | 11 | ||||
-rw-r--r-- | src/render/materialsystem/qparameter.cpp | 2 | ||||
-rw-r--r-- | src/render/render.pro | 1 | ||||
-rw-r--r-- | tests/auto/render/commons/commons.pri | 1 | ||||
-rw-r--r-- | tests/benchmarks/render/render.pro | 6 | ||||
-rw-r--r-- | tests/manual/manual.pro | 4 |
15 files changed, 38 insertions, 12 deletions
diff --git a/examples/qt3d/3d-text/main.cpp b/examples/qt3d/3d-text/main.cpp index 01243509b..8f13c24d7 100644 --- a/examples/qt3d/3d-text/main.cpp +++ b/examples/qt3d/3d-text/main.cpp @@ -81,7 +81,11 @@ int main(int argc, char *argv[]) auto *textMaterial = new Qt3DExtras::QPhongMaterial(root); { // text int i = 0; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) const QStringList fonts = QFontDatabase::families(); +#else + const QStringList fonts = QFontDatabase().families(); +#endif for (const QString &family : fonts) { 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<QNode *> QScene::lookupNodes(const QList<QNodeId> &ids) const { Q_D(const QScene); QReadLocker lock(&d->m_lock); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QList<QNode *> nodes(ids.size()); +#else + QList<QNode *> 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<QMutex> 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<GLuint64> 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<QFrameGraphNode *> QFrameGraphNodePrivate::childFrameGraphNodes() const Q_Q(const QFrameGraphNode); QList<QFrameGraphNode *> result; QQueue<QNode *> 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<QFrameGraphNode *>(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 <Qt3DRender/private/renderlogging_p.h> #include <Qt3DRender/qtexture.h> +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #include <QtCore/qiterable.h> #include <QtCore/qsequentialiterable.h> +#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) diff --git a/tests/auto/render/commons/commons.pri b/tests/auto/render/commons/commons.pri index 1c6645f8d..a91985fc4 100644 --- a/tests/auto/render/commons/commons.pri +++ b/tests/auto/render/commons/commons.pri @@ -10,5 +10,6 @@ useCommonTestAspect { } INCLUDEPATH += $$PWD +CONFIG += c++17 QT += core-private 3dcore 3dcore-private 3drender 3drender-private diff --git a/tests/benchmarks/render/render.pro b/tests/benchmarks/render/render.pro index 98d2ba1e7..96f2c306c 100644 --- a/tests/benchmarks/render/render.pro +++ b/tests/benchmarks/render/render.pro @@ -1,8 +1,10 @@ TEMPLATE=subdirs qtConfig(private_tests) { - SUBDIRS += jobs \ - layerfiltering \ + SUBDIRS += layerfiltering \ materialparametergathering \ opengl + + qtHaveModule(quick): \ + SUBDIRS += jobs } diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index 1a5689bc6..8fea8cb48 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -11,8 +11,7 @@ SUBDIRS += \ deferred-renderer-cpp \ raster-cpp \ qtbug-72236 \ - manual-renderloop \ - boundingvolumes + manual-renderloop QT_FOR_CONFIG += 3drender-private qtConfig(qt3d-rhi-renderer): { @@ -101,6 +100,7 @@ qtHaveModule(quick) { qtbug-76766 \ scene3d-in-sync \ compressed_textures \ + boundingvolumes } qtHaveModule(quickwidgets): SUBDIRS += quickwidget-switch |