Skip to content
Snippets Groups Projects
Commit 52942c2e authored by Johannes Junggeburth's avatar Johannes Junggeburth :dog2:
Browse files

Catch case when Element is already added

parent 3625de2d
No related branches found
No related tags found
1 merge request!290GeoMaterial - Remove GeoElement ref memory leak
Pipeline #6964654 canceled
...@@ -224,9 +224,10 @@ void GeoMaterial::add (const GeoElement* element, double fraction) ...@@ -224,9 +224,10 @@ void GeoMaterial::add (const GeoElement* element, double fraction)
// You can only add materials until you call "lock"... // You can only add materials until you call "lock"...
if(m_locked) throw std::out_of_range ("Element added after material locked"); if(m_locked) throw std::out_of_range ("Element added after material locked");
GeoIntrusivePtr<const GeoElement> elementPtr{element};
auto e = std::find(m_elements.begin(),m_elements.end(),element); auto e = std::find(m_elements.begin(),m_elements.end(),element);
if (e==m_elements.end()) { if (e==m_elements.end()) {
m_elements.push_back (element); m_elements.push_back (elementPtr);
m_fractions.push_back (fraction); m_fractions.push_back (fraction);
element->ref (); element->ref ();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment