[Uml-devel] KDE/kdesdk/umbrello/umbrello/codegenerators

Oliver Kellogg okellogg at users.sourceforge.net
Thu Aug 30 23:01:25 UTC 2007


SVN commit 706636 by okellogg:

{methods,constructor}Block: Add member prefix "m_".
addCodeOperation(): Avoid umbrello-import-null-pointer-backtrace-1.txt reported at
http://sourceforge.net/mailarchive/message.php?msg_name=46D283C7.80202%40freenet.de


 M  +25 -18    cppsourcecodedocument.cpp  
 M  +3 -3      cppsourcecodedocument.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/cppsourcecodedocument.cpp #706635:706636
@@ -5,7 +5,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *  copyright (C) 2003-2006                                                *
+ *  copyright (C) 2003-2007                                                *
  *  Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                   *
  ***************************************************************************/
 
@@ -67,8 +67,8 @@
 
     setFileExtension(".cpp");
 
-    methodsBlock = 0;
-    constructorBlock = 0;
+    m_methodsBlock = 0;
+    m_constructorBlock = 0;
 
     //initCodeClassFields(); // this is dubious because it calls down to
                              // CodeGenFactory::newCodeClassField(this)
@@ -84,12 +84,19 @@
 // in the vannilla version, we just tack all operations on the end
 // of the document
 bool CPPSourceCodeDocument::addCodeOperation (CodeOperation * op ) {
-
-    if(!op->getParentOperation()->isLifeOperation())
-    {
-        return methodsBlock->addTextBlock(op);
-    } else
-        return constructorBlock->addTextBlock(op);
+    bool retval = false;
+    if (op->getParentOperation()->isLifeOperation()) {
+        if (m_constructorBlock)
+            retval = m_constructorBlock->addTextBlock(op);
+        else
+            kError() << "CPPSourceCodeDocument::addCodeOperation: m_constructorBlock is NULL";
+    } else {
+        if (m_methodsBlock)
+            retval = m_methodsBlock->addTextBlock(op);
+        else
+            kError() << "CPPSourceCodeDocument::addCodeOperation: m_methodsBlock is NULL";
+    }
+    return retval;
 }
 
 
@@ -97,8 +104,8 @@
 {
 
     // all special pointers need to be zero'd out.
-    methodsBlock = 0;
-    constructorBlock = 0;
+    m_methodsBlock = 0;
+    m_constructorBlock = 0;
 
     // now do the traditional release of child text blocks
     ClassifierCodeDocument::resetTextBlocks();
@@ -150,15 +157,15 @@
     // After the includes we have just 2 big blocks basically, the "constructor" block and the
     // block for the rest of our methods (operations + accessors)
 
-    constructorBlock = getHierarchicalCodeBlock("constructionMethodsBlock", "Constructors/Destructors", 0);
-    methodsBlock = getHierarchicalCodeBlock("otherMethodsBlock", "Methods", 0);
+    m_constructorBlock = getHierarchicalCodeBlock("constructionMethodsBlock", "Constructors/Destructors", 0);
+    m_methodsBlock = getHierarchicalCodeBlock("otherMethodsBlock", "Methods", 0);
 
     // add accessors to the methods block
-    methodsBlock->addCodeClassFieldMethods(staticAttribClassFields);
-    methodsBlock->addCodeClassFieldMethods(attribClassFields);
-    methodsBlock->addCodeClassFieldMethods(plainAssocClassFields);
-    methodsBlock->addCodeClassFieldMethods(aggregationClassFields);
-    methodsBlock->addCodeClassFieldMethods(compositionClassFields);
+    m_methodsBlock->addCodeClassFieldMethods(staticAttribClassFields);
+    m_methodsBlock->addCodeClassFieldMethods(attribClassFields);
+    m_methodsBlock->addCodeClassFieldMethods(plainAssocClassFields);
+    m_methodsBlock->addCodeClassFieldMethods(aggregationClassFields);
+    m_methodsBlock->addCodeClassFieldMethods(compositionClassFields);
 
     // constructors and other operations are handled by the "addCodeOperation" method above.
 
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/cppsourcecodedocument.h #706635:706636
@@ -5,7 +5,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   copyright (C) 2004-2006                                               *
+ *   copyright (C) 2004-2007                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
@@ -63,8 +63,8 @@
 
 private:
 
-    HierarchicalCodeBlock * constructorBlock;
-    HierarchicalCodeBlock * methodsBlock;
+    HierarchicalCodeBlock * m_constructorBlock;
+    HierarchicalCodeBlock * m_methodsBlock;
 
     void init ( );
 




More information about the umbrello-devel mailing list