[Uml-devel] branches/KDE/4.2/kdesdk/umbrello/umbrello

Ralf Habacker Ralf.Habacker at freenet.de
Mon Jan 26 23:01:19 UTC 2009


SVN commit 917136 by habacker:

backported crash fix 917128

 M  +19 -1     classifier.cpp  
 M  +11 -2     umlcanvasobject.cpp  
 M  +3 -1      umlnamespace.h  


--- branches/KDE/4.2/kdesdk/umbrello/umbrello/classifier.cpp #917135:917136
@@ -222,6 +222,7 @@
 
 bool UMLClassifier::addOperation(UMLOperation* op, int position )
 {
+    Q_ASSERT(op);
     if (m_List.indexOf(op) != -1) {
         uDebug() << "findRef(" << op->getName() << ") finds op (bad)";
         return false;
@@ -327,6 +328,7 @@
 {
     UMLAttributeList attributeList;
     foreach (UMLObject* listItem , m_List ) {
+        uIgnoreZeroPointer(listItem);
         if (listItem->getBaseType() == Uml::ot_Attribute) {
             attributeList.append(static_cast<UMLAttribute*>(listItem));
         }
@@ -342,6 +344,7 @@
         UMLAttributeList atl = getAttributeList();
         foreach(UMLAttribute* at, atl )
         {
+            uIgnoreZeroPointer(at);
             if (! at->getStatic())
             {
                 if (scope == Uml::Visibility::Private)
@@ -370,6 +373,7 @@
         UMLAttributeList atl = getAttributeList();
         foreach(UMLAttribute* at, atl )
         {
+            uIgnoreZeroPointer(at);
             if (at->getStatic())
             {
                 if (scope == Uml::Visibility::Private)
@@ -395,6 +399,7 @@
     const bool caseSensitive = UMLApp::app()->activeLanguageIsCaseSensitive();
     UMLOperationList list;
     foreach (UMLObject*  obj, m_List) {
+        uIgnoreZeroPointer(obj);
         if (obj->getBaseType() != Uml::ot_Operation)
             continue;
         UMLOperation *op = static_cast<UMLOperation*>(obj);
@@ -434,6 +439,7 @@
     UMLClassifierList inheritingConcepts;
     Uml::IDType myID = getID();
     foreach(UMLClassifier *c , list ) {
+        uIgnoreZeroPointer(c);
         if (type == ALL || (!c->isInterface() && type == CLASS)
                 || (c->isInterface() && type == INTERFACE)) {
             inheritingConcepts.append(c);
@@ -441,6 +447,7 @@
     }
 
     foreach (UMLAssociation *a , rlist ) {
+        uIgnoreZeroPointer(a);
         if (a->getObjectId(A) != myID)
         {
             UMLObject* obj = a->getObject(A);
@@ -465,6 +472,7 @@
     UMLClassifierList parentConcepts;
     Uml::IDType myID = getID();
     foreach (UMLClassifier *concept , list ) {
+        uIgnoreZeroPointer(concept);
         if (type == ALL || (!concept->isInterface() && type == CLASS)
                 || (concept->isInterface() && type == INTERFACE))
             parentConcepts.append(concept);
@@ -520,6 +528,7 @@
     bool success = UMLPackage::resolveRef();
     // Using reentrant iteration is a bare necessity here:
     foreach (UMLObject* obj, m_List ) {
+        uIgnoreZeroPointer(obj);
         /**** For reference, here is the non-reentrant iteration scheme -
               DO NOT USE THIS !
         for (UMLObject *obj = m_List.first(); obj; obj = m_List.next())
@@ -614,6 +623,7 @@
 UMLAttribute* UMLClassifier::addAttribute(const QString &name, Uml::IDType id /* = Uml::id_None */)
 {
     foreach (UMLObject* obj, m_List ) {
+        uIgnoreZeroPointer(obj);
         if (obj->getBaseType() == Uml::ot_Attribute && obj->getName() == name)
             return static_cast<UMLAttribute*>(obj);
     }
@@ -645,6 +655,7 @@
 bool UMLClassifier::addAttribute(UMLAttribute* att, IDChangeLog* log /* = 0 */,
                                  int position /* = -1 */)
 {
+    Q_ASSERT(att);
     if (findChildObject(att->getName()) == NULL) {
         att->setParent(this);
         if (position >= 0 && position < (int)m_List.count()) {
@@ -693,6 +704,7 @@
 {
     UMLOperationList opl( getOpList() );
     foreach(UMLOperation *op , opl ) {
+        uIgnoreZeroPointer(op);
         if (op->getAbstract()) {
             return true;
         }
@@ -709,6 +721,7 @@
 {
     UMLOperationList ops;
     foreach (UMLObject* li, m_List) {
+        uIgnoreZeroPointer(li);
         if (li->getBaseType() == ot_Operation) {
             ops.append(static_cast<UMLOperation*>(li));
         }
@@ -744,7 +757,8 @@
 {
     UMLClassifierListItemList resultList;
     foreach (UMLObject* o, m_List) {
-        if (o->getBaseType() == Uml::ot_Association) {
+        uIgnoreZeroPointer(o);
+        if (!o || o->getBaseType() == Uml::ot_Association) {
             continue;
         }
         UMLClassifierListItem *listItem = static_cast<UMLClassifierListItem*>(o);
@@ -841,6 +855,7 @@
 {
     UMLTemplateList templateList;
     foreach (UMLObject* listItem, m_List) {
+        uIgnoreZeroPointer(listItem);
         if (listItem->getBaseType() == Uml::ot_Template) {
             templateList.append(static_cast<UMLTemplate*>(listItem));
         }
@@ -852,6 +867,7 @@
 {
     QString buf;
     foreach (UMLObject* currentAtt, m_List ) {
+        uIgnoreZeroPointer(currentAtt);
         QString txt = currentAtt->getName();
         if (txt.isEmpty()) {
            txt = "Type-" + QString::number((int) currentAtt->getBaseType());
@@ -994,6 +1010,7 @@
     UMLAssociationList uniAssocListToBeImplemented;
 
     foreach (UMLAssociation *a , associations ) {
+        uIgnoreZeroPointer(a);
         if (a->getObjectId(Uml::B) == getID()) {
             continue;  // we need to be at the A side
         }
@@ -1003,6 +1020,7 @@
             bool found = false;
             //make sure that an attribute with the same name doesn't already exist
             foreach (UMLAttribute *at , atl ) {
+                uIgnoreZeroPointer(a);
                 if (at->getName() == roleNameB) {
                     found = true;
                     break;
--- branches/KDE/4.2/kdesdk/umbrello/umbrello/umlcanvasobject.cpp #917135:917136
@@ -57,6 +57,7 @@
     UMLObject *o = NULL;
     for (UMLObjectListIt oit(m_List); oit.hasNext(); ) {
         o = oit.next();
+        uIgnoreZeroPointer(o);
         if (o->getBaseType() != Uml::ot_Association)
             continue;
         UMLAssociation *a = static_cast<UMLAssociation*>(o);
@@ -68,6 +69,7 @@
 
 bool UMLCanvasObject::addAssociationEnd(UMLAssociation* assoc)
 {
+    Q_ASSERT(assoc);
     // add association only if not already present in list
     if(!hasAssociation(assoc))
     {
@@ -101,10 +103,10 @@
 
 void UMLCanvasObject::removeAllAssociationEnds()
 {
-    for (int i = 0; i < m_List.count(); ) {
+    for (int i = 0; i < m_List.count(); i++) {
         UMLObject *o = m_List.at(i);
+        uIgnoreZeroPointer(o);
         if (o->getBaseType() != Uml::ot_Association) {
-            ++i;
             continue;
         }
         UMLAssociation *assoc = static_cast<UMLAssociation*>(o);
@@ -190,6 +192,7 @@
     UMLObject *obj = NULL;
     for (UMLObjectListIt oit(m_List); oit.hasNext(); ) {
         obj = oit.next();
+        uIgnoreZeroPointer(obj);
         if (t != Uml::ot_UMLObject && obj->getBaseType() != t)
             continue;
         if (caseSensitive) {
@@ -208,6 +211,7 @@
     UMLObject *o = NULL;
     for (UMLObjectListIt oit(m_List); oit.hasNext(); ) {
         o = oit.next();
+        uIgnoreZeroPointer(o);
         if (o->getID() == id)
             return o;
     }
@@ -247,6 +251,7 @@
     UMLObject *obj = NULL;
     for (UMLObjectListIt oit(m_List); oit.hasNext(); ) {
         obj = oit.next();
+        uIgnoreZeroPointer(obj);
         if (obj->getBaseType() == Uml::ot_Association)
             count++;
     }
@@ -259,6 +264,7 @@
     UMLObject *o = NULL;
     for (UMLObjectListIt oit(m_List); oit.hasNext() ; ) {
         o = oit.next();
+        uIgnoreZeroPointer(o);
         if (o->getBaseType() != Uml::ot_Association)
             continue;
         UMLAssociation *assoc = static_cast<UMLAssociation*>(o);
@@ -272,6 +278,7 @@
     UMLClassifierList list;
     UMLAssociationList assocs = getAssociations();
     foreach (UMLAssociation* a , assocs ) {
+        uIgnoreZeroPointer(a);
         if ((a->getAssocType() != Uml::at_Generalization &&
              a->getAssocType() != Uml::at_Realization) ||
                 a->getObjectId(Uml::A) != getID() )
@@ -291,6 +298,7 @@
     UMLClassifierList list;
     UMLAssociationList assocs = getAssociations();
     foreach (UMLAssociation* a , assocs ) {
+        uIgnoreZeroPointer(a);
         if ((a->getAssocType() != Uml::at_Generalization &&
              a->getAssocType() != Uml::at_Realization) ||
                 a->getObjectId(Uml::B) != getID() )
@@ -330,6 +338,7 @@
     bool overallSuccess = UMLObject::resolveRef();
     for (UMLObjectListIt ait(m_List); ait.hasNext(); ) {
         UMLObject *obj = ait.next();
+        uIgnoreZeroPointer(obj);
         if (! obj->resolveRef()) {
             m_List.removeAll(obj);
             overallSuccess = false;
--- branches/KDE/4.2/kdesdk/umbrello/umbrello/umlnamespace.h #917135:917136
@@ -14,8 +14,8 @@
 
 #include <string>
 #include <QtCore/QString>
+#include <kdebug.h>
 
-
 /**
  *@author Paul Hensgen
  * Bugs and comments to uml-devel at lists.sf.net or http://bugs.kde.org
@@ -324,6 +324,8 @@
 #define uError()   kError(8060)
 #define uWarning() kWarning(8060)
 
+#define uIgnoreZeroPointer(a) if (!a) { uDebug() << "zero pointer detected" << __FILE__ << __LINE__; continue; }
+
 /**
  * Function for comparing tags in XMI files.
  */




More information about the umbrello-devel mailing list