From 8609543a5b85678345d29d83b0642b4375ad7918 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 6 May 2016 14:51:59 +0200 Subject: [PATCH] Protect against load of empty MED file. --- .../MEDReader/ParaViewPlugin/pqMEDReaderFieldsWidget.cxx | 3 +++ .../ParaViewPlugin/pqMEDReaderTimesFlagsWidget.cxx | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderFieldsWidget.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderFieldsWidget.cxx index f06f0616..c6f74bbb 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderFieldsWidget.cxx +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderFieldsWidget.cxx @@ -73,6 +73,9 @@ void pqMEDReaderFieldsWidget::loadTreeWidgetItems() vtkStringArray* names = vtkStringArray::SafeDownCast(tree->GetVertexData()->GetAbstractArray("Names")); + if(!names)// In case of error right at the begining of loading process (empty MED file) + return ; + vtkIdType root = tree->GetRoot(); vtkIdType fst = tree->GetChild(root, 0); // FieldsStatusTree diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimesFlagsWidget.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimesFlagsWidget.cxx index 2aaf97f5..60e57e14 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimesFlagsWidget.cxx +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderTimesFlagsWidget.cxx @@ -77,6 +77,9 @@ pqMEDReaderTimesFlagsWidget::pqMEDReaderTimesFlagsWidget( this->addPropertyLink(this, "timeSteps", SIGNAL(timeStepsChanged()), smproxy, smproperty); + if(!this->TimesVectWidget) // In case of error right at the begining of loading process (empty MED file) + return ; + const QMap& items(this->TimesVectWidget->getItems()); QMap::const_iterator it; for (it = items.begin(); it != items.end(); it++) @@ -103,6 +106,8 @@ QList< QList< QVariant> > pqMEDReaderTimesFlagsWidget::getTimeSteps() const // Put together a TimeStep list, using ItemMap QList< QList< QVariant> > ret; QList< QVariant > timeStep; + if(!this->TimesVectWidget) // In case of error right at the begining of loading process (empty MED file) + return ret; const QMap& items(this->TimesVectWidget->getItems()); QMap::const_iterator it; for (it = items.begin(); it != items.end(); it++) @@ -165,6 +170,9 @@ void pqMEDReaderTimesFlagsWidget::CreateTimesVectWidget() delete this->TimesVectWidget; } + if(!graph) + return ;// In case of error right at the begining of loading process (empty MED file) + // (Re)cretate widget this->TimesVectWidget = new VectBoolWidget(this, pqMedReaderGraphUtils::getMaxNumberOfTS(graph)); -- 2.39.2