mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-01 03:37:15 -06:00
Avoid crash when adding a grid case multiple times
This commit is contained in:
parent
179e269fcc
commit
4a673b7cd5
@ -115,8 +115,10 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
|
|||||||
project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr;
|
project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr;
|
||||||
if ( sumCaseColl )
|
if ( sumCaseColl )
|
||||||
{
|
{
|
||||||
std::vector<RimSummaryCase*> newSumCases = sumCaseColl->createSummaryCasesFromFileInfos( summaryFileInfos );
|
std::vector<RimSummaryCase*> candidateCases = sumCaseColl->createSummaryCasesFromFileInfos( summaryFileInfos );
|
||||||
for ( RimSummaryCase* newSumCase : newSumCases )
|
std::vector<RimSummaryCase*> duplicatedCases;
|
||||||
|
|
||||||
|
for ( RimSummaryCase* newSumCase : candidateCases )
|
||||||
{
|
{
|
||||||
RimSummaryCaseCollection* existingCollection = nullptr;
|
RimSummaryCaseCollection* existingCollection = nullptr;
|
||||||
QString gridCaseFile =
|
QString gridCaseFile =
|
||||||
@ -130,7 +132,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
|
|||||||
auto* existingFileSummaryCase = dynamic_cast<RimFileSummaryCase*>( existingSummaryCase );
|
auto* existingFileSummaryCase = dynamic_cast<RimFileSummaryCase*>( existingSummaryCase );
|
||||||
if ( existingGridSummaryCase )
|
if ( existingGridSummaryCase )
|
||||||
{
|
{
|
||||||
delete newSumCase; // No need to add anything new. Already have one.
|
duplicatedCases.push_back( newSumCase );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if ( existingFileSummaryCase )
|
else if ( existingFileSummaryCase )
|
||||||
@ -183,7 +185,8 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
|
|||||||
|
|
||||||
// Remove existing case
|
// Remove existing case
|
||||||
sumCaseColl->removeCase( existingFileSummaryCase );
|
sumCaseColl->removeCase( existingFileSummaryCase );
|
||||||
delete existingFileSummaryCase;
|
|
||||||
|
duplicatedCases.push_back( existingFileSummaryCase );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( existingCollection )
|
if ( existingCollection )
|
||||||
@ -197,10 +200,18 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
|
|||||||
sumCaseColl->updateAllRequiredEditors();
|
sumCaseColl->updateAllRequiredEditors();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !newSumCases.empty() )
|
// Delete cases that already was present
|
||||||
|
for ( auto duplicateCase : duplicatedCases )
|
||||||
{
|
{
|
||||||
RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( { newSumCases.front() }, {} );
|
candidateCases.erase( std::remove( candidateCases.begin(), candidateCases.end(), duplicateCase ),
|
||||||
RiuPlotMainWindowTools::setExpanded( newSumCases.front() );
|
candidateCases.end() );
|
||||||
|
delete duplicateCase;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !candidateCases.empty() )
|
||||||
|
{
|
||||||
|
RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( { candidateCases.front() }, {} );
|
||||||
|
RiuPlotMainWindowTools::setExpanded( candidateCases.front() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,3 +220,11 @@ def test_selected_cells(rips_instance, initialize_test):
|
|||||||
# Try to read for SOIL the time step (will be empty since nothing is selected)
|
# Try to read for SOIL the time step (will be empty since nothing is selected)
|
||||||
soil_results = case.selected_cell_property("DYNAMIC_NATIVE", "SOIL", tidx)
|
soil_results = case.selected_cell_property("DYNAMIC_NATIVE", "SOIL", tidx)
|
||||||
assert len(soil_results) == 0
|
assert len(soil_results) == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_multiple_load_of_same_case(rips_instance, initialize_test):
|
||||||
|
# Test related to issue https://github.com/OPM/ResInsight/issues/9332
|
||||||
|
path_name = dataroot.PATH + "/flow_diagnostics_test/SIMPLE_SUMMARY2.EGRID"
|
||||||
|
case_count = 3
|
||||||
|
for i in range(case_count):
|
||||||
|
case = rips_instance.project.load_case(path_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user