mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 06:38:13 -05:00
#4529 Remove nextValidId fields and calculate on the fly
Remove cached next-valid-ID member variables and compute them on demand by scanning existing objects, following the pattern already used by RimUserDefinedCalculationCollection. This eliminates unnecessary state and potential corruption risks. Fixes #4529.
This commit is contained in:
1 parent
2374301385
commit
5921c44be0
6 files changed
+52
-71
No files matched your search
+11
-7
@@ -21,7 +21,6 @@
|
||||
#include "RimCase.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimFracture.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimStimPlanModelTemplate.h"
|
||||
|
||||
@@ -29,6 +28,8 @@
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmObjectScriptingCapability.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimStimPlanModelTemplateCollection, "StimPlanModelTemplateCollection" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -40,8 +41,9 @@ RimStimPlanModelTemplateCollection::RimStimPlanModelTemplateCollection()
|
||||
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_stimPlanModelTemplates, "StimPlanModelTemplates", "StimPlan Model Templates" );
|
||||
|
||||
CAF_PDM_InitField( &m_nextValidId, "NextValidId", 0, "" );
|
||||
m_nextValidId.uiCapability()->setUiHidden( true );
|
||||
CAF_PDM_InitField( &m_nextValidId_OBSOLETE, "NextValidId", 0, "" );
|
||||
m_nextValidId_OBSOLETE.xmlCapability()->setIOWritable( false );
|
||||
m_nextValidId_OBSOLETE.uiCapability()->setUiHidden( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -106,10 +108,12 @@ void RimStimPlanModelTemplateCollection::initAfterRead()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimStimPlanModelTemplateCollection::nextFractureTemplateId()
|
||||
{
|
||||
int newId = m_nextValidId;
|
||||
m_nextValidId = m_nextValidId + 1;
|
||||
|
||||
return newId;
|
||||
int nextValidId = 0;
|
||||
for ( const auto& templ : m_stimPlanModelTemplates )
|
||||
{
|
||||
nextValidId = std::max( nextValidId, templ->id() + 1 );
|
||||
}
|
||||
return nextValidId;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -50,5 +50,5 @@ private:
|
||||
int nextFractureTemplateId();
|
||||
|
||||
caf::PdmChildArrayField<RimStimPlanModelTemplate*> m_stimPlanModelTemplates;
|
||||
caf::PdmField<int> m_nextValidId; // Unique fracture template ID within a project
|
||||
caf::PdmField<int> m_nextValidId_OBSOLETE;
|
||||
};
|
||||
Reference in new issue
Block a user