mirror of https://github.com/qt/qt3d.git
Fix incorrect usages of std::make_move_iterator
In several places, std::make_move_iterator was used to move from a const vector, which is not possible and fell back to copy. Use the existing Qt3DCore::moveAtEnd utility to ensure a move operation is actually happening. * When readability permits, pass directly a return value as second parameter; * Otherwise, std::move from a mutable vector. Change-Id: I56c8925bbdeab95257d0a7fa89cffcda53fd6451 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
This commit is contained in:
parent
43a7aad707
commit
b15f62e323
|
@ -17,6 +17,7 @@
|
|||
#include <Qt3DCore/private/qnode_p.h>
|
||||
#include <Qt3DCore/private/qscene_p.h>
|
||||
#include <Qt3DCore/private/qnode_p.h>
|
||||
#include <Qt3DCore/private/vector_helper_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -303,9 +304,7 @@ std::vector<QAspectJobPtr> QAbstractAspectPrivate::jobsToExecute(qint64 time)
|
|||
|
||||
{
|
||||
QMutexLocker lock(&m_singleShotMutex);
|
||||
res.insert(res.end(),
|
||||
std::make_move_iterator(m_singleShotJobs.begin()),
|
||||
std::make_move_iterator(m_singleShotJobs.end()));
|
||||
Qt3DCore::moveAtEnd(res, std::move(m_singleShotJobs));
|
||||
m_singleShotJobs.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <Qt3DCore/private/qaspectmanager_p.h>
|
||||
#include <Qt3DCore/private/qaspectjob_p.h>
|
||||
#include <Qt3DCore/private/qabstractaspectjobmanager_p.h>
|
||||
#include <Qt3DCore/private/vector_helper_p.h>
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDateTime>
|
||||
|
@ -86,10 +87,8 @@ int QScheduler::scheduleAndWaitForFrameAspectJobs(qint64 time, bool dumpJobs)
|
|||
// For now just queue them up as they are
|
||||
const QList<QAbstractAspect *> &aspects = m_aspectManager->aspects();
|
||||
for (QAbstractAspect *aspect : aspects) {
|
||||
const std::vector<QAspectJobPtr> aspectJobs = QAbstractAspectPrivate::get(aspect)->jobsToExecute(time);
|
||||
jobQueue.insert(jobQueue.end(),
|
||||
std::make_move_iterator(aspectJobs.begin()),
|
||||
std::make_move_iterator(aspectJobs.end()));
|
||||
std::vector<QAspectJobPtr> aspectJobs = QAbstractAspectPrivate::get(aspect)->jobsToExecute(time);
|
||||
Qt3DCore::moveAtEnd(jobQueue, std::move(aspectJobs));
|
||||
}
|
||||
|
||||
if (jobQueue.empty())
|
||||
|
|
|
@ -54,8 +54,8 @@
|
|||
#include <Qt3DInput/private/updateaxisactionjob_p.h>
|
||||
#include <Qt3DCore/private/qeventfilterservice_p.h>
|
||||
#include <Qt3DCore/private/qservicelocator_p.h>
|
||||
|
||||
#include <Qt3DCore/private/qaspectmanager_p.h>
|
||||
#include <Qt3DCore/private/vector_helper_p.h>
|
||||
|
||||
#ifdef HAVE_QGAMEPAD
|
||||
# include <Qt3DInput/private/qgamepadinput_p.h>
|
||||
|
@ -202,8 +202,8 @@ std::vector<QAspectJobPtr> QInputAspect::jobsToExecute(qint64 time)
|
|||
|
||||
const auto integrations = d->m_inputHandler->inputDeviceIntegrations();
|
||||
for (QInputDeviceIntegration *integration : integrations) {
|
||||
const std::vector<QAspectJobPtr> integrationJobs = integration->jobsToExecute(time);
|
||||
jobs.insert(jobs.end(), std::make_move_iterator(integrationJobs.begin()), std::make_move_iterator(integrationJobs.end()));
|
||||
std::vector<QAspectJobPtr> integrationJobs = integration->jobsToExecute(time);
|
||||
Qt3DCore::moveAtEnd(jobs, std::move(integrationJobs));
|
||||
}
|
||||
|
||||
const QList<Qt3DCore::QNodeId> proxiesToLoad = d->m_inputHandler->physicalDeviceProxyManager()->takePendingProxiesToLoad();
|
||||
|
|
|
@ -148,6 +148,7 @@
|
|||
#include <Qt3DCore/private/qaspectmanager_p.h>
|
||||
#include <Qt3DCore/private/qeventfilterservice_p.h>
|
||||
#include <Qt3DCore/private/calcboundingvolumejob_p.h>
|
||||
#include <Qt3DCore/private/vector_helper_p.h>
|
||||
|
||||
#include <QThread>
|
||||
#include <QOpenGLContext>
|
||||
|
@ -667,11 +668,9 @@ std::vector<Qt3DCore::QAspectJobPtr> QRenderAspect::jobsToExecute(qint64 time)
|
|||
jobs.push_back(job);
|
||||
}
|
||||
|
||||
const std::vector<QAspectJobPtr> geometryJobs = d->createGeometryRendererJobs();
|
||||
jobs.insert(jobs.end(), std::make_move_iterator(geometryJobs.begin()), std::make_move_iterator(geometryJobs.end()));
|
||||
Qt3DCore::moveAtEnd(jobs, d->createGeometryRendererJobs());
|
||||
|
||||
const std::vector<QAspectJobPtr> preRenderingJobs = d->createPreRendererJobs();
|
||||
jobs.insert(jobs.end(), std::make_move_iterator(preRenderingJobs.begin()), std::make_move_iterator(preRenderingJobs.end()));
|
||||
Qt3DCore::moveAtEnd(jobs, d->createPreRendererJobs());
|
||||
|
||||
// Don't spawn any rendering jobs, if the renderer decides to skip this frame
|
||||
// Note: this only affects rendering jobs (jobs that load buffers,
|
||||
|
@ -723,8 +722,7 @@ std::vector<Qt3DCore::QAspectJobPtr> QRenderAspect::jobsToExecute(qint64 time)
|
|||
if (layersDirty)
|
||||
jobs.push_back(d->m_updateEntityLayersJob);
|
||||
|
||||
const std::vector<QAspectJobPtr> renderBinJobs = d->m_renderer->renderBinJobs();
|
||||
jobs.insert(jobs.end(), std::make_move_iterator(renderBinJobs.begin()), std::make_move_iterator(renderBinJobs.end()));
|
||||
Qt3DCore::moveAtEnd(jobs, d->m_renderer->renderBinJobs());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
|
|
|
@ -442,9 +442,7 @@ struct HighestPriorityHitReducer
|
|||
HitList reduceToAllHits(HitList &results, const HitList &intermediate)
|
||||
{
|
||||
if (!intermediate.empty())
|
||||
results.insert(results.end(),
|
||||
std::make_move_iterator(intermediate.begin()),
|
||||
std::make_move_iterator(intermediate.end()));
|
||||
results.insert(results.end(), intermediate.begin(), intermediate.end());
|
||||
return results;
|
||||
}
|
||||
|
||||
|
|
|
@ -174,10 +174,8 @@ bool RayCastingJob::pick(const QList<QPair<Entity *, RayCaster *>> &entities)
|
|||
gathererFunctor.m_manager = m_manager;
|
||||
gathererFunctor.m_ray = ray;
|
||||
gathererFunctor.m_objectPickersRequired = false;
|
||||
const PickingUtils::HitList &hits = gathererFunctor.computeHits(entityPicker.entities(), QPickingSettings::AllPicks);
|
||||
sphereHits.insert(sphereHits.end(),
|
||||
std::make_move_iterator(hits.begin()),
|
||||
std::make_move_iterator(hits.end()));
|
||||
PickingUtils::HitList hits = gathererFunctor.computeHits(entityPicker.entities(), QPickingSettings::AllPicks);
|
||||
Qt3DCore::moveAtEnd(sphereHits, std::move(hits));
|
||||
}
|
||||
if (pickConfiguration.edgePickingRequested) {
|
||||
PickingUtils::LineCollisionGathererFunctor gathererFunctor;
|
||||
|
@ -185,10 +183,8 @@ bool RayCastingJob::pick(const QList<QPair<Entity *, RayCaster *>> &entities)
|
|||
gathererFunctor.m_ray = ray;
|
||||
gathererFunctor.m_pickWorldSpaceTolerance = pickConfiguration.pickWorldSpaceTolerance;
|
||||
gathererFunctor.m_objectPickersRequired = false;
|
||||
const PickingUtils::HitList &hits = gathererFunctor.computeHits(entityPicker.entities(), QPickingSettings::AllPicks);
|
||||
sphereHits.insert(sphereHits.end(),
|
||||
std::make_move_iterator(hits.begin()),
|
||||
std::make_move_iterator(hits.end()));
|
||||
PickingUtils::HitList hits = gathererFunctor.computeHits(entityPicker.entities(), QPickingSettings::AllPicks);
|
||||
Qt3DCore::moveAtEnd(sphereHits, std::move(hits));
|
||||
PickingUtils::AbstractCollisionGathererFunctor::sortHits(sphereHits);
|
||||
}
|
||||
if (pickConfiguration.pointPickingRequested) {
|
||||
|
@ -197,17 +193,13 @@ bool RayCastingJob::pick(const QList<QPair<Entity *, RayCaster *>> &entities)
|
|||
gathererFunctor.m_ray = ray;
|
||||
gathererFunctor.m_pickWorldSpaceTolerance = pickConfiguration.pickWorldSpaceTolerance;
|
||||
gathererFunctor.m_objectPickersRequired = false;
|
||||
const PickingUtils::HitList &hits = gathererFunctor.computeHits(entityPicker.entities(), QPickingSettings::AllPicks);
|
||||
sphereHits.insert(sphereHits.end(),
|
||||
std::make_move_iterator(hits.begin()),
|
||||
std::make_move_iterator(hits.end()));
|
||||
PickingUtils::HitList hits = gathererFunctor.computeHits(entityPicker.entities(), QPickingSettings::AllPicks);
|
||||
Qt3DCore::moveAtEnd(sphereHits, std::move(hits));
|
||||
PickingUtils::AbstractCollisionGathererFunctor::sortHits(sphereHits);
|
||||
}
|
||||
if (!pickConfiguration.primitivePickingRequested) {
|
||||
const PickingUtils::HitList &hits = entityPicker.hits();
|
||||
sphereHits.insert(sphereHits.end(),
|
||||
std::make_move_iterator(hits.begin()),
|
||||
std::make_move_iterator(hits.end()));
|
||||
PickingUtils::HitList hits = entityPicker.hits();
|
||||
Qt3DCore::moveAtEnd(sphereHits, std::move(hits));
|
||||
PickingUtils::AbstractCollisionGathererFunctor::sortHits(sphereHits);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue