mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Do not allow opening the same odb file twice. The odb reader does not support that.
This commit is contained in:
parent
8ecd3c3c33
commit
cbadfd456a
@ -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 );
|
||||
|
@ -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 )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user