Do not allow opening the same odb file twice. The odb reader does not support that.

This commit is contained in:
Jon Jenssen 2020-09-14 17:06:16 +02:00 committed by Magne Sjaastad
parent 8ecd3c3c33
commit cbadfd456a
2 changed files with 25 additions and 7 deletions

View File

@ -853,15 +853,8 @@ bool RiaApplication::openOdbCaseFromFile( const QString& fileName, bool applyTim
QFileInfo gridFileName( fileName );
QString caseName = gridFileName.completeBaseName();
RimGeoMechCase* geoMechCase = new RimGeoMechCase();
geoMechCase->setGridFileName( fileName );
geoMechCase->caseUserDescription = caseName;
geoMechCase->setApplyTimeFilter( applyTimeStepFilter );
m_project->assignCaseIdToCase( geoMechCase );
RimGeoMechModels* geoMechModelCollection = m_project->activeOilField() ? m_project->activeOilField()->geoMechModels()
: nullptr;
// Create the geoMech model container if it is not there already
if ( geoMechModelCollection == nullptr )
{
@ -869,6 +862,22 @@ bool RiaApplication::openOdbCaseFromFile( const QString& fileName, bool applyTim
m_project->activeOilField()->geoMechModels = geoMechModelCollection;
}
// Check if the file is already open, the odb reader does not support opening the same file twice very well
for ( auto gmcase : geoMechModelCollection->cases() )
{
if ( gmcase->gridFileName() == fileName )
{
RiaLogging::warning( "File has already been opened. Cannot open the file twice! - " + fileName );
return false;
}
}
RimGeoMechCase* geoMechCase = new RimGeoMechCase();
geoMechCase->setGridFileName( fileName );
geoMechCase->caseUserDescription = caseName;
geoMechCase->setApplyTimeFilter( applyTimeStepFilter );
m_project->assignCaseIdToCase( geoMechCase );
RimGeoMechView* riv = geoMechCase->createAndAddReservoirView();
caf::ProgressInfo progress( 11, "Loading Case" );
progress.setNextProgressIncrement( 10 );

View File

@ -78,6 +78,15 @@ RimGeoMechCase* RimGeoMechModels::copyCase( RimGeoMechCase* thecase, const QStri
{
std::vector<RimGeoMechCase*> newcases;
for ( auto gmcase : m_cases() )
{
if ( gmcase->gridFileName() == newInputFileName )
{
RiaLogging::warning( "File has already been opened. Cannot open the file twice! - " + newInputFileName );
return nullptr;
}
}
RimGeoMechCase* copy = thecase->createCopy( newInputFileName );
if ( !copy )
{