[Uml-devel] branches/work/soc-umbrello

Gopala Krishna A krishna.ggk at gmail.com
Sat Mar 21 21:09:05 UTC 2009


SVN commit 942495 by gopala:

Merged revisions 916990,917128 via svnmerge from 
svn+ssh://svn.kde.org/home/kde/trunk/KDE/kdesdk/umbrello

........
  r916990 | fischer | 2009-01-26 22:12:16 +0530 (Mon, 26 Jan 2009) | 1 line
  
  Fixing two compiler warnings and moving the comments from h to cpp.
........
  r917128 | habacker | 2009-01-27 04:09:44 +0530 (Tue, 27 Jan 2009) | 7 lines
  
  crash fix: ignore some zero pointers - they may be valid
  To reduce the number of thoses crashes now and to be able to trace 
  those cases in the future a macro uIgnoreZeroPtr(a) has been defined. 
  It prints a debug message where the pointer ignore occurs and 
  continues in the related loop. This macro is added to places 
  where possible zero pointers may be possible.
........


 _M            . (directory)  
 M  +19 -1     umbrello/classifier.cpp  
 M  +17 -0     umbrello/codegenerators/textblock.cpp  
 M  +2 -24     umbrello/codegenerators/textblock.h  
 M  +20 -20    umbrello/codeimport/import_utils.cpp  
 M  +0 -2      umbrello/codeimport/import_utils.h  
 M  +11 -2     umbrello/umlcanvasobject.cpp  
 M  +2 -0      umbrello/umlnamespace.h  


** branches/work/soc-umbrello #property svnmerge-integrated
   - /trunk/KDE/kdesdk/umbrello:1-854015,854687,854787,855207-866962,866965-870129,871091,872169-887978,889968-889981,890075-890805,896752-896872,901256-910119,911086,911706-911805,912902,913652,916104,916343
   + /trunk/KDE/kdesdk/umbrello:1-854015,854687,854787,855207-866962,866965-870129,871091,872169-887978,889968-889981,890075-890805,896752-896872,901256-910119,911086,911706-911805,912902,913652,916104,916343,916990-917128
--- branches/work/soc-umbrello/umbrello/classifier.cpp #942494:942495
@@ -287,6 +287,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;
@@ -421,6 +422,7 @@
 {
     UMLAttributeList attributeList;
     foreach (UMLObject* listItem , m_List ) {
+        uIgnoreZeroPointer(listItem);
         if (listItem->getBaseType() == Uml::ot_Attribute) {
             attributeList.append(static_cast<UMLAttribute*>(listItem));
         }
@@ -442,6 +444,7 @@
         UMLAttributeList atl = getAttributeList();
         foreach(UMLAttribute* at, atl )
         {
+            uIgnoreZeroPointer(at);
             if (! at->getStatic())
             {
                 if (scope == Uml::Visibility::Private)
@@ -476,6 +479,7 @@
         UMLAttributeList atl = getAttributeList();
         foreach(UMLAttribute* at, atl )
         {
+            uIgnoreZeroPointer(at);
             if (at->getStatic())
             {
                 if (scope == Uml::Visibility::Private)
@@ -507,6 +511,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);
@@ -552,6 +557,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);
@@ -559,6 +565,7 @@
     }
 
     foreach (UMLAssociation *a , rlist ) {
+        uIgnoreZeroPointer(a);
         if (a->getObjectId(A) != myID)
         {
             UMLObject* obj = a->getObject(A);
@@ -589,6 +596,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);
@@ -659,6 +667,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())
@@ -763,6 +772,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);
     }
@@ -806,6 +816,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()) {
@@ -873,6 +884,7 @@
 {
     UMLOperationList opl( getOpList() );
     foreach(UMLOperation *op , opl ) {
+        uIgnoreZeroPointer(op);
         if (op->getAbstract()) {
             return true;
         }
@@ -900,6 +912,7 @@
 {
     UMLOperationList ops;
     foreach (UMLObject* li, m_List) {
+        uIgnoreZeroPointer(li);
         if (li->getBaseType() == ot_Operation) {
             ops.append(static_cast<UMLOperation*>(li));
         }
@@ -942,7 +955,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);
@@ -1077,6 +1091,7 @@
 {
     UMLTemplateList templateList;
     foreach (UMLObject* listItem, m_List) {
+        uIgnoreZeroPointer(listItem);
         if (listItem->getBaseType() == Uml::ot_Template) {
             templateList.append(static_cast<UMLTemplate*>(listItem));
         }
@@ -1096,6 +1111,7 @@
 {
     QString buf;
     foreach (UMLObject* currentAtt, m_List ) {
+        uIgnoreZeroPointer(currentAtt);
         QString txt = currentAtt->getName();
         if (txt.isEmpty()) {
            txt = "Type-" + QString::number((int) currentAtt->getBaseType());
@@ -1275,6 +1291,7 @@
     UMLAssociationList uniAssocListToBeImplemented;
 
     foreach (UMLAssociation *a , associations ) {
+        uIgnoreZeroPointer(a);
         if (a->getObjectId(Uml::B) == getID()) {
             continue;  // we need to be at the A side
         }
@@ -1284,6 +1301,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/work/soc-umbrello/umbrello/codegenerators/textblock.cpp #942494:942495
@@ -36,6 +36,9 @@
     setText(text);
 }
 
+/**
+ * Destructor.
+ */
 TextBlock::~TextBlock ()
 {
 }
@@ -317,6 +320,8 @@
  */
 void TextBlock::setAttributesOnNode ( QDomDocument & doc, QDomElement & blockElement)
 {
+    Q_UNUSED(doc);
+
     QString endLine = UMLApp::app()->getCommonPolicy()->getNewLineEndingChars();
 
     blockElement.setAttribute("tag",getTag());
@@ -416,3 +421,15 @@
        << ", text=" << obj.getText();
     return os;
 }
+
+/**
+ * Save the XMI representation of this object
+ * @param doc    the xmi document
+ * @param root   the starting point to append
+ */
+
+/**
+ * Load params from the appropriate XMI element node.
+ * @param root   the starting point in the xmi document to load from
+ */
+
--- branches/work/soc-umbrello/umbrello/codegenerators/textblock.h #942494:942495
@@ -28,30 +28,21 @@
 public:
 
     explicit TextBlock ( CodeDocument * parent, const QString & text = "");
-
-    /**
-     * Destructor.
-     */
     virtual ~TextBlock ( );
 
     void setText ( const QString & text );
-
+    QString getText() const;
     void appendText ( const QString & text );
 
-    QString getText() const;
-
+    void setTag( const QString & value );
     QString getTag() const;
 
-    void setTag( const QString & value );
-
     CodeDocument * getParentDocument() const;
 
     void setWriteOutText( bool write );
-
     bool getWriteOutText() const;
 
     void setIndentationLevel( int level );
-
     int getIndentationLevel() const;
 
     QString getIndentationString ( int level = 0) const;
@@ -69,20 +60,9 @@
     virtual QString toString() const;
 
     static QString encodeText(const QString & text , const QString & endChars);
-
     static QString decodeText(const QString & text, const QString & endChars);
 
-    /**
-     * Save the XMI representation of this object
-     * @param doc    the xmi document
-     * @param root   the starting point to append
-     */
     virtual void saveToXMI ( QDomDocument & doc, QDomElement & root ) = 0;
-
-    /**
-     * Load params from the appropriate XMI element node.
-     * @param root   the starting point in the xmi document to load from
-     */
     virtual void loadFromXMI ( QDomElement & root ) = 0;
 
     bool canDelete() const;
@@ -92,7 +72,6 @@
     virtual QString getNewEditorLine( int indentAmount = 0 );
 
     virtual int firstEditableLine();
-
     virtual int lastEditableLine();
 
 protected:
@@ -102,7 +81,6 @@
     virtual void release ();
 
     virtual void setAttributesOnNode ( QDomDocument & doc, QDomElement & blockElement);
-
     virtual void setAttributesFromNode ( QDomElement & element);
 
     friend QTextStream& operator<<(QTextStream& os, const TextBlock& obj);
--- branches/work/soc-umbrello/umbrello/codeimport/import_utils.cpp #942494:942495
@@ -325,6 +325,7 @@
 
 /**
  * Create a UMLAttribute and insert it into the document.
+ * Use the specified existing attrType.
  */
 UMLObject* insertAttribute(UMLClassifier *owner,
                            Uml::Visibility scope,
@@ -335,9 +336,9 @@
 {
     Uml::Object_Type ot = owner->getBaseType();
     Uml::Programming_Language pl = UMLApp::app()->getActiveLanguage();
-    if (! (ot == Uml::ot_Class || ot == Uml::ot_Interface && pl == Uml::pl_Java)) {
+    if (! (ot == Uml::ot_Class || (ot == Uml::ot_Interface && pl == Uml::pl_Java))) {
         uDebug() << "insertAttribute: Don not know what to do with "
-        << owner->getName() << " (object type " << ot << ")";
+                 << owner->getName() << " (object type " << ot << ")";
         return NULL;
     }
     UMLObject *o = owner->findChildObject(name, Uml::ot_Attribute);
@@ -358,7 +359,6 @@
 
 /**
  * Create a UMLAttribute and insert it into the document.
- * Use the specified existing attrType.
  */
 UMLObject* insertAttribute(UMLClassifier *owner, Uml::Visibility scope,
                            const QString& name,
@@ -380,23 +380,23 @@
 }
 
 /**
- * Insert the UMLOperation into the given classifier.
- *
- * @param klass  The classifier into which the operation shall be added.
- * @param op     Reference to pointer to the temporary UMLOperation
- *               for insertion.  The caller relinquishes ownership of the
- *               object pointed to.  If an UMLOperation of same signature
- *               already exists  at the classifier then the incoming
- *               UMLOperation is deleted and the pointer is set to the
- *               existing UMLOperation.
- * @param scope  The Uml::Visibility of the method
- * @param type   The return type
- * @param isStatic boolean switch to decide if method is static
- * @param isAbstract boolean switch to decide if method is abstract
- * @param isFriend true boolean switch to decide if methods is a friend function
- * @param isConstructor boolean switch to decide if methods is a constructor
- * @param comment The Documentation for this method
- */
+  * Insert the UMLOperation into the given classifier.
+  *
+  * @param klass          The classifier into which the operation shall be added.
+  * @param op             Reference to pointer to the temporary UMLOperation
+  *                       for insertion.  The caller relinquishes ownership of the
+  *                       object pointed to.  If an UMLOperation of same signature
+  *                       already exists  at the classifier then the incoming
+  *                       UMLOperation is deleted and the pointer is set to the
+  *                       existing UMLOperation.
+  * @param scope          The Uml::Visibility of the method
+  * @param type           The return type
+  * @param isStatic       boolean switch to decide if method is static
+  * @param isAbstract     boolean switch to decide if method is abstract
+  * @param isFriend       true boolean switch to decide if methods is a friend function
+  * @param isConstructor  boolean switch to decide if methods is a constructor
+  * @param comment        The Documentation for this method
+  */
 void insertMethod(UMLClassifier *klass, UMLOperation* &op,
                   Uml::Visibility scope, const QString& type,
                   bool isStatic, bool isAbstract,
--- branches/work/soc-umbrello/umbrello/codeimport/import_utils.h #942494:942495
@@ -46,7 +46,6 @@
                                const QString& type,
                                const QString& comment = QString(),
                                bool isStatic = false);
-
     UMLObject* insertAttribute(UMLClassifier *klass, Uml::Visibility scope,
                                const QString& name,
                                UMLClassifier *attrType,
@@ -69,7 +68,6 @@
                         const QString &comment = QString());
 
     void createGeneralization(UMLClassifier *child, UMLClassifier *parent);
-
     void createGeneralization(UMLClassifier *child, const QString &parentName);
 
     QString formatComment(const QString &comment);
--- branches/work/soc-umbrello/umbrello/umlcanvasobject.cpp #942494:942495
@@ -69,6 +69,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);
@@ -86,6 +87,7 @@
  */
 bool UMLCanvasObject::addAssociationEnd(UMLAssociation* assoc)
 {
+    Q_ASSERT(assoc);
     // add association only if not already present in list
     if(!hasAssociation(assoc))
     {
@@ -133,10 +135,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);
@@ -241,6 +243,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) {
@@ -266,6 +269,7 @@
     UMLObject *o = NULL;
     for (UMLObjectListIt oit(m_List); oit.hasNext(); ) {
         o = oit.next();
+        uIgnoreZeroPointer(o);
         if (o->getID() == id)
             return o;
     }
@@ -315,6 +319,7 @@
     UMLObject *obj = NULL;
     for (UMLObjectListIt oit(m_List); oit.hasNext(); ) {
         obj = oit.next();
+        uIgnoreZeroPointer(obj);
         if (obj->getBaseType() == Uml::ot_Association)
             count++;
     }
@@ -332,6 +337,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);
@@ -352,6 +358,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() )
@@ -378,6 +385,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() )
@@ -440,6 +448,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/work/soc-umbrello/umbrello/umlnamespace.h #942494:942495
@@ -343,4 +343,6 @@
     Class(const Class &);                       \
     Class &operator=(const Class &);
 
+#define uIgnoreZeroPointer(a) if (!a) { uDebug() << "zero pointer detected" << __FILE__ << __LINE__; continue; }
+
 #endif




More information about the umbrello-devel mailing list