summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2016-09-12 21:23:20 (GMT)
committerRalf Habacker <ralf.habacker@freenet.de>2016-09-12 21:23:20 (GMT)
commitad83879702d80a4e85df7a14f50935dbb1f7d012 (patch)
treedd10d9e8c0e329564456df72652e7223238c63e2
parent03513107a4fc0703bba116f98888c3c35ec6767c (diff)
Fix coverity check CID 169655: (USE_AFTER_FREE)
Passing freed pointer "umlobject" as an argument to "sigObjectRemoved".sigObjectRemoved. The 'object removed' signal is now emitted before object destroying. CCBUG:340646
-rw-r--r--umbrello/umldoc.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/umbrello/umldoc.cpp b/umbrello/umldoc.cpp
index b88b3e1..bfc75bc 100644
--- a/umbrello/umldoc.cpp
+++ b/umbrello/umldoc.cpp
@@ -1885,8 +1885,9 @@ void UMLDoc::removeUMLObject(UMLObject* umlobject, bool deleteObject)
}
} else {
if (type == UMLObject::ot_Association) {
- UMLAssociation *a = (UMLAssociation *)umlobject;
+ UMLAssociation *a = umlobject->asUMLAssociation();
removeAssociation(a, false); // don't call setModified here, it's done below
+ emit sigObjectRemoved(umlobject);
if (deleteObject)
delete a;
} else {
@@ -1921,13 +1922,13 @@ void UMLDoc::removeUMLObject(UMLObject* umlobject, bool deleteObject)
}
}
pkg->removeObject(umlobject);
+ emit sigObjectRemoved(umlobject);
if (deleteObject)
delete umlobject;
} else {
uError() << umlobject->name() << ": parent package is not set !";
}
}
- emit sigObjectRemoved(umlobject);
}
setModified(true);
}