mirror of
https://github.com/OPM/ResInsight.git
synced 2024-12-29 10:21:54 -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;
|
||||
if ( sumCaseColl )
|
||||
{
|
||||
std::vector<RimSummaryCase*> newSumCases = sumCaseColl->createSummaryCasesFromFileInfos( summaryFileInfos );
|
||||
for ( RimSummaryCase* newSumCase : newSumCases )
|
||||
std::vector<RimSummaryCase*> candidateCases = sumCaseColl->createSummaryCasesFromFileInfos( summaryFileInfos );
|
||||
std::vector<RimSummaryCase*> duplicatedCases;
|
||||
|
||||
for ( RimSummaryCase* newSumCase : candidateCases )
|
||||
{
|
||||
RimSummaryCaseCollection* existingCollection = nullptr;
|
||||
QString gridCaseFile =
|
||||
@ -130,7 +132,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
|
||||
auto* existingFileSummaryCase = dynamic_cast<RimFileSummaryCase*>( existingSummaryCase );
|
||||
if ( existingGridSummaryCase )
|
||||
{
|
||||
delete newSumCase; // No need to add anything new. Already have one.
|
||||
duplicatedCases.push_back( newSumCase );
|
||||
continue;
|
||||
}
|
||||
else if ( existingFileSummaryCase )
|
||||
@ -183,7 +185,8 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
|
||||
|
||||
// Remove existing case
|
||||
sumCaseColl->removeCase( existingFileSummaryCase );
|
||||
delete existingFileSummaryCase;
|
||||
|
||||
duplicatedCases.push_back( existingFileSummaryCase );
|
||||
}
|
||||
}
|
||||
if ( existingCollection )
|
||||
@ -197,10 +200,18 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
|
||||
sumCaseColl->updateAllRequiredEditors();
|
||||
}
|
||||
|
||||
if ( !newSumCases.empty() )
|
||||
// Delete cases that already was present
|
||||
for ( auto duplicateCase : duplicatedCases )
|
||||
{
|
||||
RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( { newSumCases.front() }, {} );
|
||||
RiuPlotMainWindowTools::setExpanded( newSumCases.front() );
|
||||
candidateCases.erase( std::remove( candidateCases.begin(), candidateCases.end(), duplicateCase ),
|
||||
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)
|
||||
soil_results = case.selected_cell_property("DYNAMIC_NATIVE", "SOIL", tidx)
|
||||
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