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

Oliver Kellogg okellogg at users.sourceforge.net
Thu Mar 22 23:11:52 UTC 2007


SVN commit 645578 by okellogg:

Add missing calls to initCodeClassFields() and synchronize() on newly 
 constructed ClassifierCodeDocument child class instances.
BUG:131528


 M  +3 -0      ChangeLog  
 M  +15 -11    umbrello/codegenerator.cpp  
 M  +8 -1      umbrello/codegenerator.h  
 M  +8 -2      umbrello/codegenerators/codegenfactory.cpp  
 M  +3 -1      umbrello/codegenerators/cppcodegenerator.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #645577:645578
@@ -5,11 +5,14 @@
 * Java interface inheritance, abstract classes and generics in code generation
   (53376)
 * Code generation ignores unidirectional association (72042)
+* Design bug in advanced code generators (84739)
 * %date% and %time% not being parsed (96612)
 * Operations of the Interface are not implemented in the class automatically
   (111593)
 * Relationships for entities do not live outside of the diagram (125146)
 * Multiplicity labels often are placed incorrectly (127628)
+* Crash on adding operation to class with Advanced Code Generators enabled
+  (131528)
 * Javascript wrong Code Generation (135527)
 * Javascript Code Generation creates bad format methods (135540)
 * Incorrect Association Properties text (139872)
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerator.cpp #645577:645578
@@ -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>                  *
  ***************************************************************************/
 
@@ -57,16 +57,14 @@
 CodeGenerator::CodeGenerator ()
         : QObject (UMLApp::app()->getDocument())
 {
-    initFields(UMLApp::app()->getDocument());
-    CodeGenerationPolicy *commonPolicy = UMLApp::app()->getCommonPolicy();
-    connect(commonPolicy,SIGNAL(modifiedCodeContent()),this,SLOT(syncCodeToDocument()));
+    initFields();
 }
 
 // FIX
 // hmm. this should be pure virtual so that implemented in sub-class
 CodeGenerator::CodeGenerator (QDomElement & element )
         : QObject (UMLApp::app()->getDocument()) {
-    initFields(UMLApp::app()->getDocument());
+    initFields();
     loadFromXMI(element); // hmm. cant call this here.. its 'pure' virtual
 }
 
@@ -653,9 +651,9 @@
     return output;
 }
 
-void CodeGenerator::initFields ( UMLDoc * doc ) {
+void CodeGenerator::initFields() {
 
-    m_document = doc;
+    m_document = UMLApp::app()->getDocument();
     m_codeDocumentDictionary.setAutoDelete(false);
     m_codedocumentVector.setAutoDelete(false);
     m_applyToAllRemaining = true;
@@ -667,11 +665,17 @@
     // We should only call from the child
     // initFromParentDocument();
 
-    connect(doc,SIGNAL(sigObjectCreated(UMLObject*)),this,SLOT(checkAddUMLObject(UMLObject*)));
-    connect(doc,SIGNAL(sigObjectRemoved(UMLObject*)),this,SLOT(checkRemoveUMLObject(UMLObject*)));
+}
+
+void CodeGenerator::connect_newcodegen_slots() {
+    UMLDoc *doc = UMLApp::app()->getDocument();
+    connect(doc, SIGNAL(sigObjectCreated(UMLObject*)),
+            this, SLOT(checkAddUMLObject(UMLObject*)));
+    connect(doc, SIGNAL(sigObjectRemoved(UMLObject*)),
+            this, SLOT(checkRemoveUMLObject(UMLObject*)));
     CodeGenerationPolicy *commonPolicy = UMLApp::app()->getCommonPolicy();
-    connect(commonPolicy,SIGNAL(modifiedCodeContent()),this,SLOT(syncCodeToDocument()));
-
+    connect(commonPolicy, SIGNAL(modifiedCodeContent()),
+            this, SLOT(syncCodeToDocument()));
 }
 
 // these are utility methods for accessing the default
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerator.h #645577:645578
@@ -312,6 +312,13 @@
     */
     virtual void initFromParentDocument( );
 
+    /**
+     * Connect additional slots.
+     * Only required for Advanced Code Generators.
+     * To be called after constructing the code generator (see CodeGenFactory)
+     */
+    void connect_newcodegen_slots();
+
 protected:
 
     /**
@@ -378,7 +385,7 @@
     CodeDocumentList m_codedocumentVector;
     int lastIDIndex;
 
-    void initFields ( UMLDoc * doc ) ;
+    void initFields() ;
 
 public slots:
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/codegenfactory.cpp #645577:645578
@@ -102,10 +102,12 @@
             obj = new ASWriter();
             break;
         case Uml::pl_Cpp:
-            if (optionState.generalState.newcodegen)
+            if (optionState.generalState.newcodegen) {
                 obj = new CPPCodeGenerator();
-            else
+                obj->connect_newcodegen_slots();
+            } else {
                 obj = new CppWriter();
+            }
             {
                 CPPCodeGenerationPolicy *p =
                     new CPPCodeGenerationPolicy(UMLApp::app()->getConfig());
@@ -121,6 +123,7 @@
         case Uml::pl_Java:
             if (optionState.generalState.newcodegen) {
                 obj = new JavaCodeGenerator();
+                obj->connect_newcodegen_slots();
                 JavaCodeGenerationPolicy *p =
                     new JavaCodeGenerationPolicy(UMLApp::app()->getConfig());
                 UMLApp::app()->setPolicyExt(p);
@@ -148,6 +151,7 @@
         case Uml::pl_Ruby:
             if (optionState.generalState.newcodegen) {
                 obj = new RubyCodeGenerator();
+                obj->connect_newcodegen_slots();
                 RubyCodeGenerationPolicy *p =
                     new RubyCodeGenerationPolicy(UMLApp::app()->getConfig());
                 UMLApp::app()->setPolicyExt(p);
@@ -191,6 +195,8 @@
         default:
             break;
     }
+    retval->initCodeClassFields();
+    retval->synchronize();
     return retval;
 }
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/cppcodegenerator.cpp #645577:645578
@@ -282,7 +282,8 @@
         CodeDocument * codeDoc = findCodeDocumentByClassifier(c);
         if (!codeDoc)
         {
-            codeDoc = new CPPSourceCodeDocument(c);
+            codeDoc = newClassifierCodeDocument(c);
+            codeDoc->synchronize();
             addCodeDocument(codeDoc); // this will also add a unique tag to the code document
         }
 
@@ -290,6 +291,7 @@
         if (!hcodeDoc)
         {
             hcodeDoc = newHeaderClassifierCodeDocument(c);
+            hcodeDoc->synchronize();
             addHeaderCodeDocument(hcodeDoc); // this will also add a unique tag to the code document
         }
     }




More information about the umbrello-devel mailing list