mirror of https://github.com/qt/qtgraphs.git
Fix endless sync loop in Bars3D
Floor was updated in each sync, triggering some dirty flags
being set. Update floor only if something affecting it changes.
Pick-to: 6.9
Fixes: QTBUG-136174
Change-Id: I172a8b443fd6d65f9cac3390071329f95a731f47
Reviewed-by: Sakaria Pouke <sakaria.pouke@qt.io>
Reviewed-by: Kwanghyo Park <kwanghyo.park@qt.io>
(cherry picked from commit f62322d262)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
aadd8fd9e7
commit
7a25a45ced
|
|
@ -956,6 +956,7 @@ void QQuickGraphsBars::componentComplete()
|
|||
m_floorBackground->setParentItem(m_floorBackgroundRotation);
|
||||
|
||||
m_floorBackground->setSource(floorUrl);
|
||||
m_floorBackground->setPickable(false);
|
||||
|
||||
setFloorGridInRange(true);
|
||||
setVerticalSegmentLine(false);
|
||||
|
|
@ -1007,13 +1008,24 @@ void QQuickGraphsBars::synchData()
|
|||
|
||||
QQuickGraphsItem::synchData();
|
||||
|
||||
// Draw floor
|
||||
if (m_selectedBarPos.isNull())
|
||||
itemLabel()->setVisible(false);
|
||||
|
||||
//margin for a line to be fully visible on the edge in the grid shader
|
||||
// Draw floor
|
||||
if (m_changeTracker.floorChanged) {
|
||||
updateFloor();
|
||||
m_changeTracker.floorChanged = false;
|
||||
}
|
||||
|
||||
qCDebug(lcGraphs3D, "%s end syncing", qUtf8Printable(QLatin1String(__FUNCTION__)));
|
||||
}
|
||||
|
||||
void QQuickGraphsBars::updateFloor()
|
||||
{
|
||||
// Margin for a line to be fully visible on the edge in the grid shader
|
||||
const float halfLineWidth = 50.0;
|
||||
const float gridTextureSize = 4096.0;
|
||||
const float gridMargin = halfLineWidth / gridTextureSize;
|
||||
m_floorBackground->setPickable(false);
|
||||
auto min = qMin(scaleWithBackground().x(), scaleWithBackground().z());
|
||||
m_floorBackgroundScale->setScale(QVector3D(scaleWithBackground().x() + gridMargin,
|
||||
min * gridOffset(),
|
||||
|
|
@ -1035,10 +1047,6 @@ void QQuickGraphsBars::synchData()
|
|||
bgMatFloor = static_cast<QQuick3DCustomMaterial *>(bbRef.at(0));
|
||||
materialsRefF.append(bgMatFloor);
|
||||
}
|
||||
if (m_selectedBarPos.isNull())
|
||||
itemLabel()->setVisible(false);
|
||||
|
||||
qCDebug(lcGraphs3D, "%s end syncing", qUtf8Printable(QLatin1String(__FUNCTION__)));
|
||||
}
|
||||
|
||||
void QQuickGraphsBars::updateParameters()
|
||||
|
|
@ -1198,6 +1206,7 @@ void QQuickGraphsBars::calculateSceneScalingFactors()
|
|||
setScaleWithBackground(scale);
|
||||
setBackgroundScaleMargin({m_hBackgroundMargin, m_vBackgroundMargin, m_hBackgroundMargin});
|
||||
setScale(scale);
|
||||
m_changeTracker.floorChanged = true;
|
||||
}
|
||||
|
||||
void QQuickGraphsBars::calculateHeightAdjustment()
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ struct Bars3DChangeBitField
|
|||
bool floorLevelChanged : 1;
|
||||
bool barSeriesMarginChanged : 1;
|
||||
bool axisRangeChanged : 1;
|
||||
bool floorChanged : 1;
|
||||
|
||||
Bars3DChangeBitField()
|
||||
: multiSeriesScalingChanged(true)
|
||||
|
|
@ -45,6 +46,7 @@ struct Bars3DChangeBitField
|
|||
, floorLevelChanged(false)
|
||||
, barSeriesMarginChanged(false)
|
||||
, axisRangeChanged(false)
|
||||
, floorChanged(true)
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
@ -161,6 +163,7 @@ public:
|
|||
protected:
|
||||
void componentComplete() override;
|
||||
void synchData() override;
|
||||
void updateFloor();
|
||||
void updateParameters();
|
||||
void updateFloorLevel(float level);
|
||||
void updateGraph() override;
|
||||
|
|
|
|||
Loading…
Reference in New Issue