Commit 9a8a58ad authored by Ralf Habacker's avatar Ralf Habacker

Remove zero pointers in UMLCanvasObject::m_List on access.

parent ec44b8bc
...@@ -432,7 +432,6 @@ UMLAttributeList UMLClassifier::getAttributeList() const ...@@ -432,7 +432,6 @@ UMLAttributeList UMLClassifier::getAttributeList() const
{ {
UMLAttributeList attributeList; UMLAttributeList attributeList;
foreach (UMLObject* listItem, subordinates()) { foreach (UMLObject* listItem, subordinates()) {
uIgnoreZeroPointer(listItem);
if (listItem->baseType() == UMLObject::ot_Attribute) { if (listItem->baseType() == UMLObject::ot_Attribute) {
attributeList.append(listItem->asUMLAttribute()); attributeList.append(listItem->asUMLAttribute());
} }
...@@ -520,7 +519,6 @@ UMLOperationList UMLClassifier::findOperations(const QString &n) ...@@ -520,7 +519,6 @@ UMLOperationList UMLClassifier::findOperations(const QString &n)
const bool caseSensitive = UMLApp::app()->activeLanguageIsCaseSensitive(); const bool caseSensitive = UMLApp::app()->activeLanguageIsCaseSensitive();
UMLOperationList list; UMLOperationList list;
foreach (UMLObject* obj, subordinates()) { foreach (UMLObject* obj, subordinates()) {
uIgnoreZeroPointer(obj);
if (obj->baseType() != UMLObject::ot_Operation) if (obj->baseType() != UMLObject::ot_Operation)
continue; continue;
UMLOperation *op = obj->asUMLOperation(); UMLOperation *op = obj->asUMLOperation();
...@@ -652,7 +650,6 @@ void UMLClassifier::copyInto(UMLObject *lhs) const ...@@ -652,7 +650,6 @@ void UMLClassifier::copyInto(UMLObject *lhs) const
// CHECK: association property m_pClassAssoc is not copied // CHECK: association property m_pClassAssoc is not copied
subordinates().copyInto(&(target->subordinates())); subordinates().copyInto(&(target->subordinates()));
foreach(UMLObject *o, target->subordinates()) { foreach(UMLObject *o, target->subordinates()) {
uIgnoreZeroPointer(o);
o->setUMLParent(target); o->setUMLParent(target);
} }
} }
...@@ -680,7 +677,6 @@ bool UMLClassifier::resolveRef() ...@@ -680,7 +677,6 @@ bool UMLClassifier::resolveRef()
bool success = UMLPackage::resolveRef(); bool success = UMLPackage::resolveRef();
// Using reentrant iteration is a bare necessity here: // Using reentrant iteration is a bare necessity here:
foreach (UMLObject* obj, subordinates()) { foreach (UMLObject* obj, subordinates()) {
uIgnoreZeroPointer(obj);
/**** For reference, here is the non-reentrant iteration scheme - /**** For reference, here is the non-reentrant iteration scheme -
DO NOT USE THIS ! DO NOT USE THIS !
for (UMLObject *obj = subordinates().first(); obj; obj = subordinates().next()) for (UMLObject *obj = subordinates().first(); obj; obj = subordinates().next())
......
...@@ -64,7 +64,6 @@ UMLAssociationList UMLCanvasObject::getSpecificAssocs(Uml::AssociationType::Enum ...@@ -64,7 +64,6 @@ UMLAssociationList UMLCanvasObject::getSpecificAssocs(Uml::AssociationType::Enum
UMLObject *o = 0; UMLObject *o = 0;
for (UMLObjectListIt oit(subordinates()); oit.hasNext();) { for (UMLObjectListIt oit(subordinates()); oit.hasNext();) {
o = oit.next(); o = oit.next();
uIgnoreZeroPointer(o);
if (o->baseType() != UMLObject::ot_Association) if (o->baseType() != UMLObject::ot_Association)
continue; continue;
UMLAssociation *a = o->asUMLAssociation(); UMLAssociation *a = o->asUMLAssociation();
...@@ -133,7 +132,6 @@ void UMLCanvasObject::removeAllAssociationEnds() ...@@ -133,7 +132,6 @@ void UMLCanvasObject::removeAllAssociationEnds()
{ {
for (int i = 0; i < subordinates().count(); i++) { for (int i = 0; i < subordinates().count(); i++) {
UMLObject *o = subordinates().at(i); UMLObject *o = subordinates().at(i);
uIgnoreZeroPointer(o);
if (o->baseType() != UMLObject::ot_Association) { if (o->baseType() != UMLObject::ot_Association) {
continue; continue;
} }
...@@ -246,7 +244,6 @@ UMLObject * UMLCanvasObject::findChildObject(const QString &n, UMLObject::Object ...@@ -246,7 +244,6 @@ UMLObject * UMLCanvasObject::findChildObject(const QString &n, UMLObject::Object
UMLObject *obj = 0; UMLObject *obj = 0;
for (UMLObjectListIt oit(subordinates()); oit.hasNext();) { for (UMLObjectListIt oit(subordinates()); oit.hasNext();) {
obj = oit.next(); obj = oit.next();
uIgnoreZeroPointer(obj);
if (t != UMLObject::ot_UMLObject && obj->baseType() != t) if (t != UMLObject::ot_UMLObject && obj->baseType() != t)
continue; continue;
if (caseSensitive) { if (caseSensitive) {
...@@ -272,7 +269,6 @@ UMLObject* UMLCanvasObject::findChildObjectById(Uml::ID::Type id, bool considerA ...@@ -272,7 +269,6 @@ UMLObject* UMLCanvasObject::findChildObjectById(Uml::ID::Type id, bool considerA
UMLObject *o = 0; UMLObject *o = 0;
for (UMLObjectListIt oit(subordinates()); oit.hasNext();) { for (UMLObjectListIt oit(subordinates()); oit.hasNext();) {
o = oit.next(); o = oit.next();
uIgnoreZeroPointer(o);
if (o->id() == id) if (o->id() == id)
return o; return o;
} }
...@@ -325,7 +321,6 @@ int UMLCanvasObject::associations() ...@@ -325,7 +321,6 @@ int UMLCanvasObject::associations()
UMLObject *obj = 0; UMLObject *obj = 0;
for (UMLObjectListIt oit(subordinates()); oit.hasNext();) { for (UMLObjectListIt oit(subordinates()); oit.hasNext();) {
obj = oit.next(); obj = oit.next();
uIgnoreZeroPointer(obj);
if (obj->baseType() == UMLObject::ot_Association) if (obj->baseType() == UMLObject::ot_Association)
count++; count++;
} }
...@@ -343,7 +338,6 @@ UMLAssociationList UMLCanvasObject::getAssociations() ...@@ -343,7 +338,6 @@ UMLAssociationList UMLCanvasObject::getAssociations()
UMLObject *o = 0; UMLObject *o = 0;
for (UMLObjectListIt oit(subordinates()); oit.hasNext() ;) { for (UMLObjectListIt oit(subordinates()); oit.hasNext() ;) {
o = oit.next(); o = oit.next();
uIgnoreZeroPointer(o);
if (o->baseType() != UMLObject::ot_Association) if (o->baseType() != UMLObject::ot_Association)
continue; continue;
UMLAssociation *assoc = o->asUMLAssociation(); UMLAssociation *assoc = o->asUMLAssociation();
...@@ -456,7 +450,6 @@ bool UMLCanvasObject::resolveRef() ...@@ -456,7 +450,6 @@ bool UMLCanvasObject::resolveRef()
bool overallSuccess = UMLObject::resolveRef(); bool overallSuccess = UMLObject::resolveRef();
for (UMLObjectListIt ait(subordinates()); ait.hasNext();) { for (UMLObjectListIt ait(subordinates()); ait.hasNext();) {
UMLObject *obj = ait.next(); UMLObject *obj = ait.next();
uIgnoreZeroPointer(obj);
if (! obj->resolveRef()) { if (! obj->resolveRef()) {
subordinates().removeAll(obj); subordinates().removeAll(obj);
overallSuccess = false; overallSuccess = false;
......
...@@ -78,6 +78,7 @@ public: ...@@ -78,6 +78,7 @@ public:
virtual void removeAllChildObjects(); virtual void removeAllChildObjects();
UMLObjectList &subordinates() const { UMLObjectList &subordinates() const {
m_List.removeAll(0);
return m_List; return m_List;
} }
......
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