Bug 131528 - crash on adding operation to class with Advanced Code Generators enabled
Summary: crash on adding operation to class with Advanced Code Generators enabled
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR crash
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
: 130720 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-07-29 20:56 UTC by greatbunzinni
Modified: 2007-03-23 00:12 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
crash backtrace (4.97 KB, text/plain)
2006-07-29 21:07 UTC, greatbunzinni
Details

Note You need to log in before you can comment on or make changes to this bug.
Description greatbunzinni 2006-07-29 20:56:20 UTC
Version:           1.5.3 (using KDE KDE 3.5.3)

Umbrello crashed while I attempted to add a operation to a class.
Comment 1 greatbunzinni 2006-07-29 21:07:31 UTC
Created attachment 17160 [details]
crash backtrace
Comment 2 Oliver Kellogg 2006-07-30 00:14:49 UTC
Again, a new-codegen issue (CPPSourceCodeDocument)

*** This bug has been marked as a duplicate of 84739 ***
Comment 3 Oliver Kellogg 2007-03-21 06:49:07 UTC
The bug fixed by commit 644749 was covering up the true cause here. 
Comment 4 Oliver Kellogg 2007-03-21 06:51:50 UTC
*** Bug 130720 has been marked as a duplicate of this bug. ***
Comment 5 Oliver Kellogg 2007-03-23 00:11:58 UTC
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@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
         }
     }