From b5f264077b077174ba2141a7cf00036b5a38c26f Mon Sep 17 00:00:00 2001 From: boulant Date: Mon, 15 Apr 2013 16:07:39 +0000 Subject: [PATCH] Fix bug mantis 22193 A better correction should be to no display the contextual menu if the selected object is not conform --- src/MEDOP/gui/DatasourceController.cxx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/MEDOP/gui/DatasourceController.cxx b/src/MEDOP/gui/DatasourceController.cxx index 39eca5c47..c9e9149ea 100644 --- a/src/MEDOP/gui/DatasourceController.cxx +++ b/src/MEDOP/gui/DatasourceController.cxx @@ -231,6 +231,14 @@ void DatasourceController::OnExpandField() long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,OBJECT_ID); STDLOG("Expand the field timeseries "<getFieldListInFieldseries(fieldseriesId); @@ -263,6 +271,11 @@ void DatasourceController::OnVisualize() { for (int i=0; isize(); i++) { SALOMEDS::SObject_var soField = listOfSObject->at(i); int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID); + // If fieldId equals -1, then it means that it is not a field + // managed by the MED module, and we stop this function process. + if ( fieldId < 0 ) + continue; + MEDOP::FieldHandler * fieldHandler = MEDOPFactoryClient::getDataManager()->getFieldHandler(fieldId); DatasourceEvent * event = new DatasourceEvent(); @@ -303,6 +316,16 @@ void DatasourceController::OnUseInWorkspace() { } int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID); + + // If fieldId equals -1, then it means that it is not a field + // managed by the MED module, and we stop this function process. + if ( fieldId < 0 ) { + QMessageBox::warning(_salomeModule->getApp()->desktop(), + tr("Operation not allowed"), + tr("This element is not a field object")); + return; + } + MEDOP::FieldHandler * fieldHandler = MEDOPFactoryClient::getDataManager()->getFieldHandler(fieldId); -- 2.39.2