#8084 StimPlan Model: Dangling annotations when changing MD

This commit is contained in:
Kristian Bendiksen
2021-10-08 13:10:22 +02:00
parent 296c4e552a
commit 7cf56e1e87
5 changed files with 22 additions and 6 deletions

View File

@@ -73,6 +73,14 @@ void RimAnnotationCollectionBase::addAnnotation( RimTextAnnotation* annotation )
updateViewAnnotationCollections();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimAnnotationCollectionBase::removeAnnotation( RimTextAnnotation* annotation )
{
m_textAnnotations->removeAnnotation( annotation );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -44,6 +44,7 @@ public:
bool isActive() const;
void addAnnotation( RimTextAnnotation* annotation );
void removeAnnotation( RimTextAnnotation* annotation );
std::vector<RimTextAnnotation*> textAnnotations() const;

View File

@@ -90,6 +90,14 @@ void RimAnnotationGroupCollection::addAnnotation( caf::PdmObject* annotation )
m_annotations.push_back( annotation );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimAnnotationGroupCollection::removeAnnotation( caf::PdmObject* annotation )
{
m_annotations.removeChildObject( annotation );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -52,6 +52,7 @@ public:
bool isVisible() const;
void addAnnotation( caf::PdmObject* annotation );
void removeAnnotation( caf::PdmObject* annotation );
std::vector<caf::PdmObject*> annotations() const;
protected:

View File

@@ -752,16 +752,14 @@ void RimStimPlanModel::updateDistanceToBarrierAndDip()
//--------------------------------------------------------------------------------------------------
void RimStimPlanModel::clearBarrierAnnotation()
{
RimAnnotationCollectionBase* coll = annotationCollection();
auto existingTextAnnotation = m_barrierTextAnnotation.value();
if ( existingTextAnnotation )
if ( coll && existingTextAnnotation )
{
coll->removeAnnotation( existingTextAnnotation );
delete existingTextAnnotation;
m_barrierTextAnnotation = nullptr;
}
RimAnnotationCollectionBase* coll = annotationCollection();
if ( coll )
{
coll->onAnnotationDeleted();
}
}