3DScatter: Don't do unnecessary scalearray resize

When the modelhandler resolves the model, it always resizes scalearray.
This patch adds a check whether the itemmodel has scale roleindex. If
the model has no scale, it skips the resizing of scalearray.

Pick-to: 6.10
Fixes: QTBUG-141186
Change-Id: I2718987f15c751cd187f1a398a92e10c71c9fbc6
Reviewed-by: Sakaria Pouke <sakaria.pouke@qt.io>
Reviewed-by: Kwanghyo Park <kwanghyo.park@qt.io>
This commit is contained in:
Sami Varanka 2025-10-16 14:59:05 +03:00
parent aedafd8f4b
commit 77ac8a5a9a
2 changed files with 6 additions and 2 deletions

View File

@ -274,14 +274,16 @@ void ScatterItemModelHandler::resolveModel()
if (m_proxyArray.data() != m_proxy->series()->dataArray().data() if (m_proxyArray.data() != m_proxy->series()->dataArray().data()
|| totalCount != m_proxyArray.size()) { || totalCount != m_proxyArray.size()) {
m_proxyArray.resize(totalCount); m_proxyArray.resize(totalCount);
m_scaleArray.resize(totalCount); if (m_scaleRole != noRoleIndex)
m_scaleArray.resize(totalCount);
} }
// Parse data into newProxyArray // Parse data into newProxyArray
for (int i = 0; i < rowCount; i++) { for (int i = 0; i < rowCount; i++) {
for (int j = 0; j < columnCount; j++) { for (int j = 0; j < columnCount; j++) {
modelPosToScatterItem(i, j, m_proxyArray[runningCount]); modelPosToScatterItem(i, j, m_proxyArray[runningCount]);
m_scaleArray[runningCount] = modelDataToScale(i, j); if (m_scaleRole != noRoleIndex)
m_scaleArray[runningCount] = modelDataToScale(i, j);
runningCount++; runningCount++;
} }
} }

View File

@ -103,6 +103,7 @@ void tst_proxy::initialProperties()
QCOMPARE(m_proxy->zPosRoleReplace(), QString()); QCOMPARE(m_proxy->zPosRoleReplace(), QString());
QCOMPARE(m_proxy->itemCount(), 0); QCOMPARE(m_proxy->itemCount(), 0);
QCOMPARE(m_proxy->series()->scaleArray().size(), 0);
QCOMPARE(m_proxy->type(), QAbstractDataProxy::DataType::Scatter); QCOMPARE(m_proxy->type(), QAbstractDataProxy::DataType::Scatter);
} }
@ -216,6 +217,7 @@ void tst_proxy::addModel()
QCoreApplication::processEvents(); QCoreApplication::processEvents();
QCOMPARE(m_proxy->itemCount(), 2); QCOMPARE(m_proxy->itemCount(), 2);
QCOMPARE(m_proxy->series()->scaleArray().size(), 0);
QVERIFY(m_proxy->series()); QVERIFY(m_proxy->series());
QCOMPARE(m_proxy->series(), m_series); QCOMPARE(m_proxy->series(), m_series);