Commit 3b16b05c authored by Ralf Habacker's avatar Ralf Habacker

Fix incomplete UMLStereotype reference counting.

CCBUG:345546
parent c55cebc9
......@@ -59,6 +59,7 @@ UMLStereotype::UMLStereotype()
*/
UMLStereotype::~UMLStereotype()
{
Q_ASSERT(m_refCount == 0);
}
/**
......
......@@ -99,6 +99,13 @@ UMLObject::UMLObject(UMLObject * parent)
*/
UMLObject::~UMLObject()
{
// unref stereotype
setUMLStereotype(0);
if (m_pSecondary && m_pSecondary->baseType() == ot_Stereotype) {
UMLStereotype* stereotype = dynamic_cast<UMLStereotype*>(m_pSecondary.data());
if (stereotype)
stereotype->decrRefCount();
}
}
/**
......@@ -297,6 +304,8 @@ void UMLObject::copyInto(UMLObject *lhs) const
// Data members with copy constructor
lhs->m_Doc = m_Doc;
lhs->m_pStereotype = m_pStereotype;
if (lhs->m_pStereotype)
lhs->m_pStereotype->incrRefCount();
lhs->m_bAbstract = m_bAbstract;
lhs->m_bStatic = m_bStatic;
lhs->m_BaseType = m_BaseType;
......@@ -703,6 +712,8 @@ bool UMLObject::resolveRef()
m_pSecondary = pDoc->findObjectById(Uml::ID::fromString(m_SecondaryId));
if (m_pSecondary != NULL) {
if (m_pSecondary->baseType() == ot_Stereotype) {
if (m_pStereotype)
m_pStereotype->decrRefCount();
m_pStereotype = dynamic_cast<UMLStereotype*>(m_pSecondary.data());
m_pStereotype->incrRefCount();
m_pSecondary = NULL;
......@@ -881,6 +892,8 @@ bool UMLObject::loadStereotype(QDomElement & element)
return false;
Uml::ID::Type stereoID = Uml::ID::fromString(stereo);
UMLDoc *pDoc = UMLApp::app()->document();
if (m_pStereotype)
m_pStereotype->decrRefCount();
m_pStereotype = pDoc->findStereotypeById(stereoID);
if (m_pStereotype)
m_pStereotype->incrRefCount();
......@@ -972,6 +985,8 @@ bool UMLObject::loadFromXMI(QDomElement & element)
QString stereo = element.attribute(QLatin1String("stereotype"));
if (!stereo.isEmpty()) {
Uml::ID::Type stereoID = Uml::ID::fromString(stereo);
if (m_pStereotype)
m_pStereotype->decrRefCount();
m_pStereotype = umldoc->findStereotypeById(stereoID);
if (m_pStereotype) {
m_pStereotype->incrRefCount();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment