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:
committed by
Magne Sjaastad
parent
8ecd3c3c33
commit
cbadfd456a
@@ -853,15 +853,8 @@ bool RiaApplication::openOdbCaseFromFile( const QString& fileName, bool applyTim
|
|||||||
QFileInfo gridFileName( fileName );
|
QFileInfo gridFileName( fileName );
|
||||||
QString caseName = gridFileName.completeBaseName();
|
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()
|
RimGeoMechModels* geoMechModelCollection = m_project->activeOilField() ? m_project->activeOilField()->geoMechModels()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
// Create the geoMech model container if it is not there already
|
// Create the geoMech model container if it is not there already
|
||||||
if ( geoMechModelCollection == nullptr )
|
if ( geoMechModelCollection == nullptr )
|
||||||
{
|
{
|
||||||
@@ -869,6 +862,22 @@ bool RiaApplication::openOdbCaseFromFile( const QString& fileName, bool applyTim
|
|||||||
m_project->activeOilField()->geoMechModels = geoMechModelCollection;
|
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();
|
RimGeoMechView* riv = geoMechCase->createAndAddReservoirView();
|
||||||
caf::ProgressInfo progress( 11, "Loading Case" );
|
caf::ProgressInfo progress( 11, "Loading Case" );
|
||||||
progress.setNextProgressIncrement( 10 );
|
progress.setNextProgressIncrement( 10 );
|
||||||
|
|||||||
@@ -78,6 +78,15 @@ RimGeoMechCase* RimGeoMechModels::copyCase( RimGeoMechCase* thecase, const QStri
|
|||||||
{
|
{
|
||||||
std::vector<RimGeoMechCase*> newcases;
|
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 );
|
RimGeoMechCase* copy = thecase->createCopy( newInputFileName );
|
||||||
if ( !copy )
|
if ( !copy )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user