mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Guard null pointer access to currently selected object
This commit is contained in:
parent
2dd5743f18
commit
be91314ba6
@ -39,17 +39,17 @@ CAF_CMD_SOURCE_INIT( RicNewAnalysisPlotFeature, "RicNewAnalysisPlotFeature" );
|
||||
bool RicNewAnalysisPlotFeature::isCommandEnabled()
|
||||
{
|
||||
RimAnalysisPlotCollection* analysisPlotColl = nullptr;
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( selObj )
|
||||
{
|
||||
selObj->firstAncestorOrThisOfType( analysisPlotColl );
|
||||
selObj->firstAncestorOrThisOfType( summaryPlot );
|
||||
}
|
||||
|
||||
if ( analysisPlotColl ) return true;
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
selObj->firstAncestorOrThisOfType( summaryPlot );
|
||||
if ( summaryPlot ) return true;
|
||||
|
||||
return false;
|
||||
|
@ -40,17 +40,17 @@ CAF_CMD_SOURCE_INIT( RicNewCorrelationMatrixPlotFeature, "RicNewCorrelationMatri
|
||||
bool RicNewCorrelationMatrixPlotFeature::isCommandEnabled()
|
||||
{
|
||||
RimCorrelationPlotCollection* correlationPlotColl = nullptr;
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( selObj )
|
||||
{
|
||||
selObj->firstAncestorOrThisOfType( correlationPlotColl );
|
||||
selObj->firstAncestorOrThisOfType( summaryPlot );
|
||||
}
|
||||
|
||||
if ( correlationPlotColl ) return true;
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
selObj->firstAncestorOrThisOfType( summaryPlot );
|
||||
if ( summaryPlot ) return true;
|
||||
|
||||
return false;
|
||||
|
@ -37,17 +37,17 @@ CAF_CMD_SOURCE_INIT( RicNewCorrelationPlotFeature, "RicNewCorrelationPlotFeature
|
||||
bool RicNewCorrelationPlotFeature::isCommandEnabled()
|
||||
{
|
||||
RimCorrelationPlotCollection* correlationPlotColl = nullptr;
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( selObj )
|
||||
{
|
||||
selObj->firstAncestorOrThisOfType( correlationPlotColl );
|
||||
selObj->firstAncestorOrThisOfType( summaryPlot );
|
||||
}
|
||||
|
||||
if ( correlationPlotColl ) return true;
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
selObj->firstAncestorOrThisOfType( summaryPlot );
|
||||
if ( summaryPlot ) return true;
|
||||
|
||||
return false;
|
||||
|
@ -38,17 +38,17 @@ CAF_CMD_SOURCE_INIT( RicNewCorrelationReportPlotFeature, "RicNewCorrelationRepor
|
||||
bool RicNewCorrelationReportPlotFeature::isCommandEnabled()
|
||||
{
|
||||
RimCorrelationPlotCollection* correlationPlotColl = nullptr;
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( selObj )
|
||||
{
|
||||
selObj->firstAncestorOrThisOfType( correlationPlotColl );
|
||||
selObj->firstAncestorOrThisOfType( summaryPlot );
|
||||
}
|
||||
|
||||
if ( correlationPlotColl ) return true;
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
selObj->firstAncestorOrThisOfType( summaryPlot );
|
||||
if ( summaryPlot ) return true;
|
||||
|
||||
return false;
|
||||
|
@ -39,17 +39,17 @@ CAF_CMD_SOURCE_INIT( RicNewParameterResultCrossPlotFeature, "RicNewParameterResu
|
||||
bool RicNewParameterResultCrossPlotFeature::isCommandEnabled()
|
||||
{
|
||||
RimCorrelationPlotCollection* correlationPlotColl = nullptr;
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( selObj )
|
||||
{
|
||||
selObj->firstAncestorOrThisOfType( correlationPlotColl );
|
||||
selObj->firstAncestorOrThisOfType( summaryPlot );
|
||||
}
|
||||
|
||||
if ( correlationPlotColl ) return true;
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
selObj->firstAncestorOrThisOfType( summaryPlot );
|
||||
if ( summaryPlot ) return true;
|
||||
|
||||
return false;
|
||||
|
@ -45,6 +45,8 @@ bool RicNewCustomObjectiveFunctionFeature::isCommandEnabled()
|
||||
void RicNewCustomObjectiveFunctionFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( !selObj ) return;
|
||||
|
||||
std::vector<RimCustomObjectiveFunctionCollection*> coll;
|
||||
selObj->descendantsIncludingThisOfType( coll );
|
||||
|
||||
|
@ -44,6 +44,8 @@ bool RicNewCustomObjectiveFunctionWeightFeature::isCommandEnabled()
|
||||
void RicNewCustomObjectiveFunctionWeightFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( !selObj ) return;
|
||||
|
||||
std::vector<RimCustomObjectiveFunction*> func;
|
||||
selObj->descendantsIncludingThisOfType( func );
|
||||
|
||||
|
@ -53,21 +53,20 @@ CAF_CMD_SOURCE_INIT( RicNewSummaryPlotFeature, "RicNewSummaryPlotFeature" );
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewSummaryPlotFeature::isCommandEnabled()
|
||||
{
|
||||
RimSummaryPlotCollection* sumPlotColl = nullptr;
|
||||
RimSummaryPlotCollection* sumPlotColl = nullptr;
|
||||
RimCustomObjectiveFunctionCollection* customObjFuncCollection = nullptr;
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( selObj )
|
||||
{
|
||||
sumPlotColl = RiaSummaryTools::parentSummaryPlotCollection( selObj );
|
||||
selObj->firstAncestorOrThisOfType( customObjFuncCollection );
|
||||
}
|
||||
|
||||
auto ensembleFilter = dynamic_cast<RimEnsembleCurveFilter*>( selObj );
|
||||
auto ensembleFilterColl = dynamic_cast<RimEnsembleCurveFilterCollection*>( selObj );
|
||||
auto legendConfig = dynamic_cast<RimRegularLegendConfig*>( selObj );
|
||||
|
||||
RimCustomObjectiveFunctionCollection* customObjFuncCollection = nullptr;
|
||||
selObj->firstAncestorOrThisOfType( customObjFuncCollection );
|
||||
|
||||
if ( ensembleFilter || ensembleFilterColl || legendConfig || customObjFuncCollection ) return false;
|
||||
if ( sumPlotColl ) return true;
|
||||
|
||||
@ -243,12 +242,14 @@ bool RicNewDefaultSummaryPlotFeature::isCommandEnabled()
|
||||
std::vector<RimSummaryCase*> selectedIndividualSummaryCases;
|
||||
std::vector<RimSummaryCaseCollection*> selectedEnsembles;
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
|
||||
extractPlotObjectsFromSelection( &selectedIndividualSummaryCases, &selectedEnsembles );
|
||||
|
||||
RimCustomObjectiveFunctionCollection* customObjFuncCollection = nullptr;
|
||||
selObj->firstAncestorOrThisOfType( customObjFuncCollection );
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( selObj )
|
||||
{
|
||||
selObj->firstAncestorOrThisOfType( customObjFuncCollection );
|
||||
}
|
||||
|
||||
return selectedIndividualSummaryCases.empty() && selectedEnsembles.empty() && ( customObjFuncCollection == nullptr );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user