From 0825fa10aca07191099070aaab69b21a563bcda3 Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Fri, 18 Jun 2021 11:28:47 +0200 Subject: [PATCH] delete existing database file before processing a new fault (#7793) --- .../RicRunAdvFaultReactAssessmentFeature.cpp | 3 +++ .../RicRunBasicFaultReactAssessmentFeature.cpp | 3 +++ .../RicRunFaultReactAssessmentFeature.cpp | 10 +++++++++- .../RicRunFaultReactAssessmentFeature.h | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicRunAdvFaultReactAssessmentFeature.cpp b/ApplicationLibCode/Commands/GeoMechCommands/RicRunAdvFaultReactAssessmentFeature.cpp index c47e669cd6..b380eba5a9 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicRunAdvFaultReactAssessmentFeature.cpp +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicRunAdvFaultReactAssessmentFeature.cpp @@ -107,6 +107,9 @@ void RicRunAdvFaultReactAssessmentFeature::onActionTriggered( bool isChecked ) addParameterFileForCleanUp( paramfilename ); addParameterFileForCleanUp( paramfilename2 ); + // remove any existing database file + removeFile( fraSettings->advancedMacrisDatabase() ); + // run the java macris program in calibrate mode QString command = RiaPreferencesGeoMech::current()->geomechFRAMacrisCommand(); QStringList parameters = fraSettings->advancedMacrisParameters( faultID ); diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicRunBasicFaultReactAssessmentFeature.cpp b/ApplicationLibCode/Commands/GeoMechCommands/RicRunBasicFaultReactAssessmentFeature.cpp index 771db74ed2..36fd577962 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicRunBasicFaultReactAssessmentFeature.cpp +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicRunBasicFaultReactAssessmentFeature.cpp @@ -97,6 +97,9 @@ void RicRunBasicFaultReactAssessmentFeature::onActionTriggered( bool isChecked ) addParameterFileForCleanUp( paramfilename ); + // remove any existing database file + removeFile( fraSettings->basicMacrisDatabase() ); + // run the java macris program in calculate mode QString command = RiaPreferencesGeoMech::current()->geomechFRAMacrisCommand(); QStringList parameters = fraSettings->basicMacrisParameters( faultID ); diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactAssessmentFeature.cpp b/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactAssessmentFeature.cpp index 6ea7061899..ebcb03f6fb 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactAssessmentFeature.cpp +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactAssessmentFeature.cpp @@ -162,12 +162,20 @@ void RicRunFaultReactAssessmentFeature::cleanUpParameterFiles() { for ( auto& filename : m_parameterFilesToCleanUp ) { - if ( QFile::exists( filename ) ) QFile::remove( filename ); + removeFile( filename ); } } m_parameterFilesToCleanUp.clear(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicRunFaultReactAssessmentFeature::removeFile( QString filename ) +{ + if ( QFile::exists( filename ) ) QFile::remove( filename ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactAssessmentFeature.h b/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactAssessmentFeature.h index bfa3567477..ba819c0eb7 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactAssessmentFeature.h +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactAssessmentFeature.h @@ -45,6 +45,8 @@ protected: void addParameterFileForCleanUp( QString filename ); void cleanUpParameterFiles(); + void removeFile( QString filename ); + private: std::list m_parameterFilesToCleanUp; };