From fe7fbfda684d32d916a6a8ff706cabf9f647bddd Mon Sep 17 00:00:00 2001 From: Patrick Avery Date: Tue, 10 Mar 2020 09:51:46 -0400 Subject: [PATCH] Check number of scalars in properties panel update When live updates are performed on data that contains multiple scalars, the number of scalars can change in between updates. Add in a safety check in the DataPropertiesPanel to account for this. This prevents a crash. Signed-off-by: Patrick Avery --- tomviz/DataPropertiesPanel.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tomviz/DataPropertiesPanel.cxx b/tomviz/DataPropertiesPanel.cxx index b4468f967..6552b796e 100644 --- a/tomviz/DataPropertiesPanel.cxx +++ b/tomviz/DataPropertiesPanel.cxx @@ -181,11 +181,15 @@ QList DataPropertiesPanel::getArraysInfo(DataSource* dataSource) { QList arraysInfo; + // If the number of scalar arrays has changed, reset the indexes. + auto scalars = dataSource->listScalars(); + if (scalars.size() != m_scalarIndexes.size()) + m_scalarIndexes.clear(); + // If we don't have the scalar indexes, we sort the names and then save the // indexes, these will be used to preserve the displayed order even after // a rename. if (m_scalarIndexes.isEmpty()) { - auto scalars = dataSource->listScalars(); auto sortedScalars = scalars; // sort the scalars names