Bug 126262

Summary: Crashes while loading file (Advanced Code Generators enabled)
Product: [Applications] umbrello Reporter: Tijl Vercaemer <tijl>
Component: generalAssignee: Umbrello Development Group <umbrello-devel>
Status: RESOLVED INTENTIONAL    
Severity: crash CC: bernie, jmn.batista
Priority: NOR    
Version: 1.5.2   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: The file that causes Umbrello to crash
valgrind log loading attachment 15779

Description Tijl Vercaemer 2006-04-26 00:03:02 UTC
Version:           1.5.2 (using KDE KDE 3.5.2)
Installed from:    Gentoo Packages
Compiler:          gcc version 3.4.6 (Gentoo 3.4.6, ssp-3.4.5-1.0, pie-8.7.9) 
OS:                Linux

I created this file (attached) with Ubrello (same version), but when I try to open it now, Umbrello crashes.
Comment 1 Tijl Vercaemer 2006-04-26 00:04:15 UTC
Created attachment 15779 [details]
The file that causes Umbrello to crash
Comment 2 Oliver Kellogg 2006-04-26 07:29:28 UTC
Might be related or identical to bug 125331 (trace is similar)

#4  0x505a0814 in ?? ()
#5  0x082c35cf in CPPSourceCodeOperation::init(CPPSourceCodeDocument*) (
    this=0x859bc00, doc=0x89f1808) at cppsourcecodeoperation.cpp:129
#6  0x082c2af8 in CPPSourceCodeOperation (this=0x859bc00, doc=0x89f1808, 
    parent=0x8954160, body=@0xbfffddf0, comment=@0xbfffde00)
    at cppsourcecodeoperation.cpp:28
#7  0x082c201e in CPPSourceCodeDocument::newCodeOperation(UMLOperation*) (
    this=0x89f1808, op=0x8954160) at cppsourcecodedocument.cpp:136
#8  0x0814654d in ClassifierCodeDocument::updateOperations() (this=0x89f1808)
    at classifiercodedocument.cpp:441
#9  0x08146411 in ClassifierCodeDocument::synchronize() (this=0x89f1808)
    at classifiercodedocument.cpp:417
#10 0x082c1de4 in CPPSourceCodeDocument::init() (this=0x89f1808)
    at cppsourcecodedocument.cpp:89
#11 0x082c1a24 in CPPSourceCodeDocument (this=0x89f1808, concept=0x8953fe8, 
    parent=0x8960448) at cppsourcecodedocument.cpp:43
#12 0x082bf61a in CPPCodeGenerator::newClassifierCodeDocument(UMLClassifier*) (
    this=0x8960448, classifier=0x8953fe8) at cppcodegenerator.cpp:266
#13 0x082bf7a4 in CPPCodeGenerator::initFromParentDocument() (this=0x8960448)
    at cppcodegenerator.cpp:303
#14 0x082bfa6b in CPPCodeGenerator::initAttributes() (this=0x8960448)
    at cppcodegenerator.cpp:368
#15 0x082be8f8 in CPPCodeGenerator (this=0x8960448) at cppcodegenerator.cpp:39
#16 0x082ad61b in CodeGeneratorFactory::createObject(Uml::Programming_Language)
    (this=0xbfffe0d0, pl=pl_Cpp) at codegenfactory.cpp:66
#17 0x081b771c in UMLApp::createGenerator() (this=0x844ffe8) at uml.cpp:1258
#18 0x081b7621 in UMLApp::getGenerator(bool) (this=0x844ffe8, warnMissing=true)
    at uml.cpp:1233
#19 0x081cae15 in UMLDoc::addDefaultStereotypes() (this=0x845d828)
    at umldoc.cpp:2624
#20 0x081becda in UMLDoc::openDocument(KURL const&, char const*) (
    this=0x845d828, url=@0xbfffe350) at umldoc.cpp:571
#21 0x081b4d45 in UMLApp::slotFileOpen() (this=0x844ffe8) at uml.cpp:695
#22 0x081b92c5 in UMLApp::qt_invoke(int, QUObject*) (this=0x844ffe8, _id=79, 
    _o=0xbfffe450) at uml.moc:268
#23 0x40e0cc11 in QObject::activate_signal(QConnectionList*, QUObject*) ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#24 0x40e0c9e7 in QObject::activate_signal(int) ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#25 0x406bc1f6 in KAction::activated() () from /opt/kde3/lib/libkdeui.so.4
#26 0x406bb30d in KAction::slotActivated() () from /opt/kde3/lib/libkdeui.so.4
#27 0x406bb582 in KAction::slotPopupActivated() ()
   from /opt/kde3/lib/libkdeui.so.4
#28 0x406bc399 in KAction::qt_invoke(int, QUObject*) ()
   from /opt/kde3/lib/libkdeui.so.4
#29 0x40e0cc11 in QObject::activate_signal(QConnectionList*, QUObject*) ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#30 0x4115794a in QSignal::signal(QVariant const&) ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#31 0x40e27505 in QSignal::activate() () from /usr/lib/qt3/lib/libqt-mt.so.3
#32 0x40f17dc6 in QPopupMenu::mouseReleaseEvent(QMouseEvent*) ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
Comment 3 Oliver Kellogg 2006-04-26 07:33:03 UTC
*** Bug 125331 has been marked as a duplicate of this bug. ***
Comment 4 Tijl Vercaemer 2006-04-26 09:19:03 UTC
Before I submitted this bug, I opened the attachment of Bug 125331 but it didn't make Ubrello crash. It only showed an error message. This made me think this bug is different. I have however no debugging experience and have to trust your judgment.
Comment 5 Oliver Kellogg 2006-05-08 19:22:07 UTC
*** Bug 126968 has been marked as a duplicate of this bug. ***
Comment 6 Oliver Kellogg 2006-05-09 08:00:42 UTC
Requires massive cleanups but I'm getting there (see bugs 84739 and 126968)
Comment 7 Oliver Kellogg 2006-05-14 13:13:47 UTC
SVN commit 540643 by okellogg:

Continue making factory methods in CodeGenFactory for the various
classes required by the advanced code generators. This is necessary
because of call-before-construction problems (on constucting a
child object, the superclass constructor invokes a virtual method
which is reimplemented in the child - but at that point the child
object construction is not finalized => segfault)
CCBUG:126262


 M  +29 -11    classifiercodedocument.cpp  
 M  +3 -20     classifiercodedocument.h  
 M  +4 -4      codeblockwithcomments.cpp  
 M  +11 -13    codeclassfield.cpp  
 M  +0 -3      codeclassfield.h  
 M  +0 -8      codedocument.cpp  
 M  +0 -3      codedocument.h  
 M  +1 -1      codegenerators/Makefile.am  
 M  +186 -8    codegenerators/codegenfactory.cpp  
 M  +83 -2     codegenerators/codegenfactory.h  
 M  +0 -4      codegenerators/cppcodegenerator.cpp  
 M  +0 -1      codegenerators/cppcodegenerator.h  
 M  +2 -47     codegenerators/cppheadercodedocument.cpp  
 M  +0 -27     codegenerators/cppheadercodedocument.h  
 M  +5 -52     codegenerators/cppsourcecodedocument.cpp  
 M  +0 -34     codegenerators/cppsourcecodedocument.h  
 M  +5 -10     codegenerators/javaantcodedocument.cpp  
 M  +0 -3      codegenerators/javaantcodedocument.h  
 M  +2 -42     codegenerators/javaclassifiercodedocument.cpp  
 M  +0 -27     codegenerators/javaclassifiercodedocument.h  
 M  +0 -4      codegenerators/javacodegenerator.cpp  
 M  +0 -2      codegenerators/javacodegenerator.h  
 D             codegenerators/ncgof.cpp  
 D             codegenerators/ncgof.h  
 M  +3 -52     codegenerators/rubyclassifiercodedocument.cpp  
 M  +1 -34     codegenerators/rubyclassifiercodedocument.h  
 M  +1 -5      codegenerators/rubycodegenerator.cpp  
 M  +0 -2      codegenerators/rubycodegenerator.h  
 M  +7 -29     codegenobjectwithtextblocks.cpp  
 M  +0 -3      codegenobjectwithtextblocks.h  
 M  +0 -8      codemethodblock.cpp  
 M  +0 -1      codemethodblock.h  
 M  +2 -1      codeparameter.cpp  
 M  +2 -1      dialogs/codeeditor.cpp  
 M  +1 -29     hierarchicalcodeblock.cpp  
 M  +0 -13     hierarchicalcodeblock.h  
Comment 8 Oliver Kellogg 2006-05-14 13:20:12 UTC
Unfortunately, the more I see the more there is to do :-/
One particularly hiedous source of problems is class HierarchicalCodeBlock.

Here's the current trace:
#0  0x2a1e0814 in ?? ()
#1  0x082aa716 in CodeGenFactory::newCodeOperation(ClassifierCodeDocument*, UMLOperation*) (ccd=0x88ad6f0, op=0x8884338) at codegenfactory.cpp:164
#2  0x0815a1bf in CodeGenObjectWithTextBlocks::loadChildTextBlocksFromNode(QDomElement&) (this=0x893fc5c, root=@0xbfffe760)
    at codegenobjectwithtextblocks.cpp:462
#3  0x081598ec in CodeGenObjectWithTextBlocks::setAttributesFromNode(QDomElement&) (this=0x893fc5c, root=@0xbfffe760) at codegenobjectwithtextblocks.cpp:368
#4  0x0816d919 in HierarchicalCodeBlock::setAttributesFromNode(QDomElement&) (
    this=0x893fc38, root=@0xbfffe760) at hierarchicalcodeblock.cpp:283
#5  0x0816d74f in HierarchicalCodeBlock::loadFromXMI(QDomElement&) (
    this=0x893fc38, root=@0xbfffe760) at hierarchicalcodeblock.cpp:262
#6  0x08159f48 in CodeGenObjectWithTextBlocks::loadChildTextBlocksFromNode(QDomElement&) (this=0x88ad718, root=@0xbfffe980)
    at codegenobjectwithtextblocks.cpp:448
#7  0x081598ec in CodeGenObjectWithTextBlocks::setAttributesFromNode(QDomElement&) (this=0x88ad718, root=@0xbfffe980) at codegenobjectwithtextblocks.cpp:368
#8  0x08151ac7 in CodeDocument::setAttributesFromNode(QDomElement&) (
    this=0x88ad6f0, root=@0xbfffe980) at codedocument.cpp:420
#9  0x081444e4 in ClassifierCodeDocument::setAttributesFromNode(QDomElement&) (
    this=0x88ad6f0, elem=@0xbfffe980) at classifiercodedocument.cpp:588
#10 0x08144bd5 in ClassifierCodeDocument::loadFromXMI(QDomElement&) (
    this=0x88ad6f0, root=@0xbfffe980) at classifiercodedocument.cpp:680
#11 0x08155a3f in CodeGenerator::loadFromXMI(QDomElement&) (this=0x88ad368,
    qElement=@0xbfffea40) at codegenerator.cpp:208
#12 0x081c6fa7 in UMLDoc::loadExtensionsFromXMI(QDomNode&) (this=0x84595f8,
    node=@0xbfffecf0) at umldoc.cpp:2012
Comment 9 Oliver Kellogg 2006-05-15 22:54:34 UTC
I'm afraid I'm not making progress on this PR so for the time being
my only advice is, deactivate the "Use new C++/Java/Ruby code generators"
selection in the Umbrello general settings. Sorry.
Comment 10 Oliver Kellogg 2006-05-17 07:57:53 UTC
SVN commit 541722 by okellogg:

Further cleanups - but they still don't fix the problem.
CCBUG:126262


 M  +0 -1      codegenerator.cpp  
 M  +48 -15    codegenerators/codegenfactory.cpp  
 M  +6 -0      codegenerators/codegenfactory.h  
 M  +2 -2      codegenerators/cppcodeclassfield.cpp  
 M  +4 -3      codegenerators/cppcodeclassfield.h  
 M  +8 -4      codegenerators/cppcodegenerator.cpp  
 M  +6 -2      codegenerators/cppheadercodeaccessormethod.cpp  
 M  +8 -2      codegenerators/cppheadercodeaccessormethod.h  
 M  +3 -1      codegenerators/cppheadercodedocument.cpp  
 M  +6 -2      codegenerators/cppsourcecodeaccessormethod.cpp  
 M  +7 -2      codegenerators/cppsourcecodeaccessormethod.h  
 M  +3 -1      codegenerators/cppsourcecodedocument.cpp  
 M  +3 -1      codegenerators/javaclassifiercodedocument.cpp  
 M  +5 -9      codegenerators/javacodeaccessormethod.cpp  
 M  +8 -6      codegenerators/javacodeaccessormethod.h  
 M  +4 -4      codegenerators/javacodeclassfield.cpp  
 M  +3 -3      codegenerators/javacodeclassfield.h  
 M  +1 -0      codegenerators/javacodegenerator.cpp  
 M  +3 -1      codegenerators/rubyclassifiercodedocument.cpp  
 M  +5 -9      codegenerators/rubycodeaccessormethod.cpp  
 M  +6 -3      codegenerators/rubycodeaccessormethod.h  
 M  +4 -4      codegenerators/rubycodeclassfield.cpp  
 M  +3 -3      codegenerators/rubycodeclassfield.h  
 M  +1 -0      codegenerators/rubycodegenerator.cpp  
 M  +3 -1      hierarchicalcodeblock.cpp  
Comment 11 Oliver Kellogg 2007-03-24 08:05:46 UTC
Commit 644749 removed one problem layer but it still crashes as follows:

#4  0x00000000 in ?? ()
#5  0x08151236 in CodeClassField::setAttributesOnNode (this=0x89f2f30, 
    doc=@0xbfffe9d0, cfElem=@0xbfffe720)
    at /kdesdk-3.5-branch/umbrello/umbrello/codeclassfield.cpp:260
#6  0x08151812 in CodeClassField::saveToXMI (this=0x89f2f30, doc=@0xbfffe9d0, 
    root=@0xbfffe760)
    at /kdesdk-3.5-branch/umbrello/umbrello/codeclassfield.cpp:320
#7  0x08148a5a in ClassifierCodeDocument::setAttributesOnNode (this=0x89eaf60, 
    doc=@0xbfffe9d0, docElement=@0xbfffe7c0)
    at /kdesdk-3.5-branch/umbrello/umbrello/classifiercodedocument.cpp:708
#8  0x081488ac in ClassifierCodeDocument::saveToXMI (this=0x89eaf60, 
    doc=@0xbfffe9d0, root=@0xbfffe820)
    at /kdesdk-3.5-branch/umbrello/umbrello/classifiercodedocument.cpp:673
#9  0x082d7314 in CPPCodeGenerator::saveToXMI (this=0x89ea680, 
    doc=@0xbfffe9d0, root=@0xbfffe890)
at /kdesdk-3.5-branch/umbrello/umbrello/codegenerators/cppcodegenerator.cpp:172
#10 0x081c3545 in UMLDoc::saveToXMI (this=0x84dd710, file=@0x86b1d58)
    at /kdesdk-3.5-branch/umbrello/umbrello/umldoc.cpp:1323
#11 0x081c87d6 in UMLDoc::addToUndoStack (this=0x84dd710)
    at /kdesdk-3.5-branch/umbrello/umbrello/umldoc.cpp:2135
#12 0x081beb1d in UMLDoc::openDocument (this=0x84dd710, url=@0xbfffed00)
    at /kdesdk-3.5-branch/umbrello/umbrello/umldoc.cpp:499
#13 0x081b307b in UMLApp::openDocumentFile (this=0x84cdd58, url=@0xbfffed00)
    at /kdesdk-3.5-branch/umbrello/umbrello/uml.cpp:481
#14 0x0818728f in initDocument (args=0x83e3318, cfg=0x849e080)
    at /kdesdk-3.5-branch/umbrello/umbrello/main.cpp:172
Comment 12 Oliver Kellogg 2007-03-25 21:10:03 UTC
Commit 646451:
In CPPSourceCodeAccessorMethod::updateContent(), substituting

 CPPCodeClassField * cppfield = (CPPCodeClassField*)parentField;

by

 CPPCodeClassField * cppfield = dynamic_cast<CPPCodeClassField*>(parentField);

reveals that the parentField is not of the type expected (cppfield is NULL.)

The stack trace thus becomes:

#1  0x082d9109 in CPPCodeClassField::getFieldName (this=0x0)
    at codegenerators/cppcodeclassfield.cpp:57
#2  0x082dd1fa in CPPSourceCodeAccessorMethod::updateContent (this=0x89ef0d0)
    at codegenerators/cppsourcecodeaccessormethod.cpp:62
#3  0x082dcf20 in CPPSourceCodeAccessorMethod::update (this=0x89ef0d0)
    at codegenerators/cppsourcecodeaccessormethod.cpp:45
#4  0x082c3088 in CodeGenFactory::newCodeAccessorMethod (ccd=0x89e7ba8, cf=0x89efbd0, type=GET)
    at codegenerators/codegenfactory.cpp:280
#5  0x08152166 in CodeClassField::initAccessorMethods (this=0x89efbd0) at codeclassfield.cpp:427
#6  0x08152846 in CodeClassField::initFields (this=0x89efbd0) at codeclassfield.cpp:603
#7  0x081509e8 in CodeClassField (this=0x89efbd0, doc=0x89e7ba8, attrib=0x8954cf8)
    at codeclassfield.cpp:49
#8  0x082d8fd2 in CPPCodeClassField (this=0x89efbd0, parentDoc=0x89e7ba8, attrib=0x8954cf8)
    at codegenerators/cppcodeclassfield.cpp:43
#9  0x082c2e3d in CodeGenFactory::newCodeClassField (ccd=0x89e7ba8, at=0x8954cf8)
    at codegenerators/codegenfactory.cpp:234
#10 0x08147e2b in ClassifierCodeDocument::initCodeClassFields (this=0x89e7ba8)
    at classifiercodedocument.cpp:497
#11 0x082d78c6 in CPPCodeGenerator::newClassifierCodeDocument (this=0x89e7320, classifier=0x8954bf0)
    at codegenerators/cppcodegenerator.cpp:249
#12 0x082d79ff in CPPCodeGenerator::initFromParentDocument (this=0x89e7320)
    at codegenerators/cppcodegenerator.cpp:285
#13 0x082c27fb in CodeGenFactory::createObject (pl=pl_Cpp) at codegenerators/codegenfactory.cpp:176
#14 0x081b7109 in UMLApp::setGenerator (this=0x84cdd08, pl=pl_Cpp) at uml.cpp:1237
#15 0x081c6dc4 in UMLDoc::loadExtensionsFromXMI (this=0x84dd688, node=@0xbfffe970)
    at umldoc.cpp:1782
#16 0x081c488c in UMLDoc::loadFromXMI (this=0x84dd688, file=@0xbfffeb90, encode=1)
    at umldoc.cpp:1474
Comment 13 Oliver Kellogg 2007-03-26 11:29:23 UTC
SVN commit 646557 by okellogg:

CodeClassField::finishInitialization(): New method for finishing off
initializations of the object.
This is necessary as a separate method because we cannot call virtual
methods that are reimplemented in a language specific class during our
own construction (the own object is not finished being constructed and
therefore the C++ dispatch mechanism does not yet work as expected.)
CCBUG:126262


 M  +8 -3      codeclassfield.cpp  
 M  +11 -1     codeclassfield.h  
 M  +1 -0      codegenerators/codegenfactory.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeclassfield.cpp #646556:646557
@@ -37,7 +37,7 @@
 {
 
     setParentUMLObject(role);
-    initFields( );
+    initFields(true);
 
 }
 
@@ -46,7 +46,7 @@
 {
 
     setParentUMLObject(attrib);
-    initFields( );
+    initFields(true);
 
 }
 
@@ -591,7 +591,7 @@
     return false;
 }
 
-void CodeClassField::initFields ( ) {
+void CodeClassField::initFields(bool inConstructor) {
 
     m_writeOutMethods = false;
     m_listClassName = QString ("");
@@ -600,6 +600,11 @@
     m_methodVector.setAutoDelete(false);
     // m_methodMap = new QMap<CodeAccessorMethod::AccessorType, CodeAccessorMethod *>;
 
+    if (!inConstructor)
+        finishInitialization();
+}
+
+void CodeClassField::finishInitialization() {
     initAccessorMethods();
     updateContent();
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeclassfield.h #646556:646557
@@ -53,6 +53,16 @@
     CodeClassField ( ClassifierCodeDocument * parentDoc , UMLAttribute * attrib );
     CodeClassField ( ClassifierCodeDocument * parentDoc , UMLRole * role);
 
+    /**
+     * Finish off initializations of the object.
+     * This is necessary as a separate method because we cannot call
+     * virtual methods that are reimplemented in a language specific class
+     * during our own construction (the own object is not finished being
+     * constructed and therefore the C++ dispatch mechanism does not yet
+     * work as expected.)
+     */
+    void finishInitialization();
+
     // CodeClassField ( ClassifierCodeDocument * doc , UMLRole role);
 
     /**
@@ -213,7 +223,7 @@
     virtual void setAttributesFromNode ( QDomElement & element);
 
     /** init class fields */
-    void initFields (  );
+    void initFields(bool inConstructor = false);
 
     // initialize the accessor methods for this field
     void initAccessorMethods();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/codegenfactory.cpp #646556:646557
@@ -242,6 +242,7 @@
         default:
             break;
     }
+    retval->finishInitialization();
     return retval;
 }
 
Comment 14 Oliver Kellogg 2007-03-26 18:44:20 UTC
Commit 646557 addresses Comment #12.
The trace after that change:

#4  0x411492fb in QString::QString () from /usr/lib/qt3/lib/libqt-mt.so.3
#5  0x081a8ac1 in TextBlock::getTag (this=0x89f43d8) at textblock.cpp:98
#6  0x08148ca4 in ClassifierCodeDocument::findCodeClassFieldTextBlockByTag (
    this=0x89e9c50, tag=@0xbfffe2b0) at classifiercodedocument.cpp:728
#7  0x08174692 in HierarchicalCodeBlock::findCodeClassFieldTextBlockByTag (
    this=0x89c9d40, tag=@0xbfffe2b0) at hierarchicalcodeblock.cpp:362
#8  0x0815ddd5 in CodeGenObjectWithTextBlocks::loadChildTextBlocksFromNode (
    this=0x89c9d64, root=@0xbfffe490) at codegenobjectwithtextblocks.cpp:414
#9  0x0815db33 in CodeGenObjectWithTextBlocks::setAttributesFromNode (
    this=0x89c9d64, root=@0xbfffe490) at codegenobjectwithtextblocks.cpp:369
#10 0x0817414e in HierarchicalCodeBlock::setAttributesFromNode (
    this=0x89c9d40, root=@0xbfffe490) at hierarchicalcodeblock.cpp:286
#11 0x08173f7e in HierarchicalCodeBlock::loadFromXMI (this=0x89c9d40,
    root=@0xbfffe490) at hierarchicalcodeblock.cpp:265
#12 0x0815e193 in CodeGenObjectWithTextBlocks::loadChildTextBlocksFromNode (
    this=0x89e9c78, root=@0xbfffe6b0) at codegenobjectwithtextblocks.cpp:449
#13 0x0815db33 in CodeGenObjectWithTextBlocks::setAttributesFromNode (
    this=0x89e9c78, root=@0xbfffe6b0) at codegenobjectwithtextblocks.cpp:369
#14 0x08155a84 in CodeDocument::setAttributesFromNode (this=0x89e9c50,
    root=@0xbfffe6b0) at codedocument.cpp:410
#15 0x081482e1 in ClassifierCodeDocument::setAttributesFromNode (
    this=0x89e9c50, elem=@0xbfffe6b0) at classifiercodedocument.cpp:593
#16 0x081489e6 in ClassifierCodeDocument::loadFromXMI (this=0x89e9c50,
    root=@0xbfffe6b0) at classifiercodedocument.cpp:685
#17 0x08159dde in CodeGenerator::loadFromXMI (this=0x89e93c8,
    qElement=@0xbfffe770) at codegenerator.cpp:205
#18 0x081c6e5d in UMLDoc::loadExtensionsFromXMI (this=0x84dd5a0,
    node=@0xbfffe9a0) at umldoc.cpp:1783
#19 0x081c4900 in UMLDoc::loadFromXMI (this=0x84dd5a0, file=@0xbfffebc0,
    encode=1) at umldoc.cpp:1474
#20 0x081beb8c in UMLDoc::openDocument (this=0x84dd5a0, url=@0xbfffecb0)
    at umldoc.cpp:481
Comment 15 Oliver Kellogg 2007-03-26 18:47:56 UTC
SVN commit 646768 by okellogg:

Use dynamic_cast in lieu of C-style pointer cast.
CCBUG:126262


 M  +4 -3      cppheaderclassdeclarationblock.cpp  
 M  +1 -1      cppheadercodeaccessormethod.cpp  
 M  +1 -1      cppheadercodeclassfielddeclarationblock.cpp  
 M  +6 -5      cppheadercodeoperation.cpp  
 M  +1 -1      cppsourcecodeaccessormethod.cpp  
 M  +2 -2      cppsourcecodeclassfielddeclarationblock.cpp  
 M  +2 -2      cppsourcecodeoperation.cpp  
 M  +4 -3      javaclassdeclarationblock.cpp  
 M  +5 -5      javacodeaccessormethod.cpp  
 M  +2 -2      javacodeclassfielddeclarationblock.cpp  
 M  +1 -1      javacodedocumentation.cpp  
 M  +4 -3      javacodeoperation.cpp  
 M  +4 -3      rubyclassdeclarationblock.cpp  
 M  +6 -7      rubycodeaccessormethod.cpp  
 M  +2 -2      rubycodeclassfielddeclarationblock.cpp  
 M  +2 -2      rubycodeoperation.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/cppheaderclassdeclarationblock.cpp #646767:646768
@@ -24,8 +24,9 @@
 // Constructors/Destructors
 //
 
-CPPHeaderClassDeclarationBlock::CPPHeaderClassDeclarationBlock ( CPPHeaderCodeDocument * parentDoc, const QString &startText, const QString &endText, const QString &comment)
-        : OwnedHierarchicalCodeBlock((UMLObject*) parentDoc->getParentClassifier(), (CodeDocument*)parentDoc, startText, endText, comment)
+CPPHeaderClassDeclarationBlock::CPPHeaderClassDeclarationBlock
+  ( CPPHeaderCodeDocument * parentDoc, const QString &startText, const QString &endText, const QString &comment)
+        : OwnedHierarchicalCodeBlock(parentDoc->getParentClassifier(), parentDoc, startText, endText, comment)
 {
     init(parentDoc, comment);
 }
@@ -74,7 +75,7 @@
 void CPPHeaderClassDeclarationBlock::updateContent ( )
 {
 
-    CPPHeaderCodeDocument *parentDoc = (CPPHeaderCodeDocument*)getParentDocument();
+    CPPHeaderCodeDocument *parentDoc = dynamic_cast<CPPHeaderCodeDocument*>(getParentDocument());
     UMLClassifier *c = parentDoc->getParentClassifier();
     QString endLine = UMLApp::app()->getCommonPolicy()->getNewLineEndingChars();
     bool isInterface = parentDoc->parentIsInterface(); // a little shortcut
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/cppheadercodeaccessormethod.cpp #646767:646768
@@ -93,7 +93,7 @@
     ClassifierCodeDocument * doc = parentField->getParentDocument();
     CodeGenPolicyExt *pe = UMLApp::app()->getPolicyExt();
     CPPCodeGenerationPolicy * policy = dynamic_cast<CPPCodeGenerationPolicy*>(pe);
-    CPPCodeClassField * cppfield = (CPPCodeClassField*) parentField;
+    CPPCodeClassField * cppfield = dynamic_cast<CPPCodeClassField*>(parentField);
 
     bool isInlineMethod = policy->getAccessorsAreInline( );
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/cppheadercodeclassfielddeclarationblock.cpp #646767:646768
@@ -47,7 +47,7 @@
     }
 
     CodeClassField * cf = getParentClassField();
-    CPPCodeClassField * hcppcf = (CPPCodeClassField*) cf;
+    CPPCodeClassField * hcppcf = dynamic_cast<CPPCodeClassField*>(cf);
 
     // Set the comment
     QString notes = umlparent->getDoc();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/cppheadercodeoperation.cpp #646767:646768
@@ -25,8 +25,9 @@
 // Constructors/Destructors
 //
 
-CPPHeaderCodeOperation::CPPHeaderCodeOperation ( CPPHeaderCodeDocument * doc, UMLOperation *parent, const QString & body, const QString & comment )
-        : CodeOperation ((ClassifierCodeDocument*)doc, parent, body, comment)
+CPPHeaderCodeOperation::CPPHeaderCodeOperation
+ ( CPPHeaderCodeDocument * doc, UMLOperation *parent, const QString & body, const QString & comment )
+        : CodeOperation (doc, parent, body, comment)
 {
     // lets not go with the default comment and instead use
     // full-blown cpp documentation object instead
@@ -66,8 +67,8 @@
 // we basically want to update the doc and start text of this method
 void CPPHeaderCodeOperation::updateMethodDeclaration()
 {
-
-    bool isInterface = ((ClassifierCodeDocument*)getParentDocument())->parentIsInterface();
+    ClassifierCodeDocument *ccd = dynamic_cast<ClassifierCodeDocument*>(getParentDocument());
+    bool isInterface = ccd->parentIsInterface();
     UMLOperation * o = getParentOperation();
 
     CodeGenPolicyExt *pe = UMLApp::app()->getPolicyExt();
@@ -131,7 +132,7 @@
 }
 
 int CPPHeaderCodeOperation::lastEditableLine() {
-    ClassifierCodeDocument * doc = (ClassifierCodeDocument*)getParentDocument();
+    ClassifierCodeDocument * doc = dynamic_cast<ClassifierCodeDocument*>(getParentDocument());
     UMLOperation * o = getParentOperation();
     if(doc->parentIsInterface() || o->getAbstract())
         return -1; // very last line is NOT editable as its a one-line declaration w/ no body in
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/cppsourcecodeaccessormethod.cpp #646767:646768
@@ -93,7 +93,7 @@
     ClassifierCodeDocument * doc = parentField->getParentDocument();
     CodeGenPolicyExt *pe = UMLApp::app()->getPolicyExt();
     CPPCodeGenerationPolicy * policy = dynamic_cast<CPPCodeGenerationPolicy*>(pe);
-    CPPCodeClassField * cppfield = (CPPCodeClassField*) parentField;
+    CPPCodeClassField * cppfield = dynamic_cast<CPPCodeClassField*>(parentField);
     UMLClassifier * c = doc->getParentClassifier();
 
     bool isInlineMethod = policy->getAccessorsAreInline( );
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/cppsourcecodeclassfielddeclarationblock.cpp #646767:646768
@@ -44,8 +44,8 @@
     /*
     CodeClassField * cf = getParentClassField();
     ClassifierCodeDocument * doc = cf->getParentDocument();
-    CPPCodeClassField * jcf = (CPPCodeClassField*) cf;
-    CPPClassifierCodeDocument* jdoc = (CPPClassifierCodeDocument*) doc;
+    CPPCodeClassField * jcf = dynamic_cast<CPPCodeClassField*>(cf);
+    CPPClassifierCodeDocument* jdoc = dynamic_cast<CPPClassifierCodeDocument*>(doc);
 
     // Set the comment
     QString notes = getParentObject()->getDoc();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/cppsourcecodeoperation.cpp #646767:646768
@@ -26,7 +26,7 @@
 //
 
 CPPSourceCodeOperation::CPPSourceCodeOperation ( CPPSourceCodeDocument * doc, UMLOperation *parent, const QString & body, const QString & comment )
-        : CodeOperation ((ClassifierCodeDocument*)doc, parent, body, comment)
+        : CodeOperation (doc, parent, body, comment)
 {
     // lets not go with the default comment and instead use
     // full-blown cpp documentation object instead
@@ -126,7 +126,7 @@
 void CPPSourceCodeOperation::updateMethodDeclaration()
 {
 
-    CPPSourceCodeDocument * doc = (CPPSourceCodeDocument*) getParentDocument();
+    CPPSourceCodeDocument * doc = dynamic_cast<CPPSourceCodeDocument*>(getParentDocument());
     CodeGenPolicyExt *pe = UMLApp::app()->getPolicyExt();
     CPPCodeGenerationPolicy * policy = dynamic_cast<CPPCodeGenerationPolicy*>(pe);
     UMLClassifier * c = doc->getParentClassifier();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/javaclassdeclarationblock.cpp #646767:646768
@@ -22,8 +22,9 @@
 // Constructors/Destructors
 //
 
-JavaClassDeclarationBlock::JavaClassDeclarationBlock ( JavaClassifierCodeDocument * parentDoc, const QString &startText, const QString &endText, const QString &comment)
-        : OwnedHierarchicalCodeBlock((UMLObject*) parentDoc->getParentClassifier(), (CodeDocument*)parentDoc, startText, endText, comment)
+JavaClassDeclarationBlock::JavaClassDeclarationBlock
+ ( JavaClassifierCodeDocument * parentDoc, const QString &startText, const QString &endText, const QString &comment)
+        : OwnedHierarchicalCodeBlock(parentDoc->getParentClassifier(), parentDoc, startText, endText, comment)
 {
     init(parentDoc, comment);
 }
@@ -65,7 +66,7 @@
 void JavaClassDeclarationBlock::updateContent ( )
 {
 
-    JavaClassifierCodeDocument *parentDoc = (JavaClassifierCodeDocument*)getParentDocument();
+    JavaClassifierCodeDocument *parentDoc = dynamic_cast<JavaClassifierCodeDocument*>(getParentDocument());
     UMLClassifier *c = parentDoc->getParentClassifier();
     CodeGenerationPolicy *commonPolicy = UMLApp::app()->getCommonPolicy();
     QString endLine = commonPolicy->getNewLineEndingChars();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/javacodeaccessormethod.cpp #646767:646768
@@ -39,8 +39,8 @@
     setType(type);
 
     // lets use full-blown comment
-    setComment(new JavaCodeDocumentation((JavaClassifierCodeDocument*)field->getParentDocument()));
-
+    JavaClassifierCodeDocument* jccd = dynamic_cast<JavaClassifierCodeDocument*>(field->getParentDocument());
+    setComment(new JavaCodeDocumentation(jccd));
 }
 
 JavaCodeAccessorMethod::~JavaCodeAccessorMethod ( ) { }
@@ -71,7 +71,7 @@
 {
 
     CodeClassField * parentField = getParentClassField();
-    JavaCodeClassField * javafield = (JavaCodeClassField*)parentField;
+    JavaCodeClassField * javafield = dynamic_cast<JavaCodeClassField*>(parentField);
     QString fieldName = javafield->getFieldName();
 
     QString text = "";
@@ -130,8 +130,8 @@
 void JavaCodeAccessorMethod::updateMethodDeclaration()
 {
 
-    JavaCodeClassField * javafield = (JavaCodeClassField*) getParentClassField();
-    JavaClassifierCodeDocument * javadoc = (JavaClassifierCodeDocument*) javafield->getParentDocument();
+    JavaCodeClassField * javafield = dynamic_cast<JavaCodeClassField*>(getParentClassField());
+    JavaClassifierCodeDocument * javadoc = dynamic_cast<JavaClassifierCodeDocument*>(javafield->getParentDocument());
     CodeGenerationPolicy *commonpolicy = UMLApp::app()->getCommonPolicy();
 
     // gather defs
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/javacodeclassfielddeclarationblock.cpp #646767:646768
@@ -52,8 +52,8 @@
 
     CodeClassField * cf = getParentClassField();
     ClassifierCodeDocument * doc = cf->getParentDocument();
-    JavaCodeClassField * jcf = (JavaCodeClassField*) cf;
-    JavaClassifierCodeDocument* jdoc = (JavaClassifierCodeDocument*) doc;
+    JavaCodeClassField * jcf = dynamic_cast<JavaCodeClassField*>(cf);
+    JavaClassifierCodeDocument* jdoc = dynamic_cast<JavaClassifierCodeDocument*>(doc);
     CodeGenerationPolicy * commonpolicy = UMLApp::app()->getCommonPolicy();
 
     CodeGenerationPolicy::ScopePolicy scopePolicy = commonpolicy->getAssociationFieldScope();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/javacodedocumentation.cpp #646767:646768
@@ -28,7 +28,7 @@
 //
 
 JavaCodeDocumentation::JavaCodeDocumentation ( JavaClassifierCodeDocument * doc, const QString & text )
-        : CodeComment ((CodeDocument*) doc, text)
+        : CodeComment(doc, text)
 {
 
 }
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/javacodeoperation.cpp #646767:646768
@@ -24,8 +24,9 @@
 // Constructors/Destructors
 //
 
-JavaCodeOperation::JavaCodeOperation ( JavaClassifierCodeDocument * doc, UMLOperation *parent, const QString & body, const QString & comment )
-        : CodeOperation ((ClassifierCodeDocument*)doc, parent, body, comment)
+JavaCodeOperation::JavaCodeOperation
+ ( JavaClassifierCodeDocument * doc, UMLOperation *parent, const QString & body, const QString & comment )
+        : CodeOperation (doc, parent, body, comment)
 {
     // lets not go with the default comment and instead use
     // full-blown java documentation object instead
@@ -121,7 +122,7 @@
 }
 
 int JavaCodeOperation::lastEditableLine() {
-    ClassifierCodeDocument * doc = (ClassifierCodeDocument*)getParentDocument();
+    ClassifierCodeDocument * doc = dynamic_cast<ClassifierCodeDocument*>(getParentDocument());
     if(doc->parentIsInterface())
         return -1; // very last line is NOT editable as its a one-line declaration w/ no body in
     // an interface.
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/rubyclassdeclarationblock.cpp #646767:646768
@@ -25,8 +25,9 @@
 // Constructors/Destructors
 //
 
-RubyClassDeclarationBlock::RubyClassDeclarationBlock ( RubyClassifierCodeDocument * parentDoc, const QString &startText, const QString &endText, const QString &comment)
-        : OwnedHierarchicalCodeBlock((UMLObject*) parentDoc->getParentClassifier(), (CodeDocument*)parentDoc, startText, endText, comment)
+RubyClassDeclarationBlock::RubyClassDeclarationBlock
+ ( RubyClassifierCodeDocument * parentDoc, const QString &startText, const QString &endText, const QString &comment)
+        : OwnedHierarchicalCodeBlock(parentDoc->getParentClassifier(), parentDoc, startText, endText, comment)
 {
     init(parentDoc, comment);
 }
@@ -68,7 +69,7 @@
 void RubyClassDeclarationBlock::updateContent ( )
 {
 
-    RubyClassifierCodeDocument *parentDoc = (RubyClassifierCodeDocument*)getParentDocument();
+    RubyClassifierCodeDocument *parentDoc = dynamic_cast<RubyClassifierCodeDocument*>(getParentDocument());
     UMLClassifier *c = parentDoc->getParentClassifier();
     CodeGenerationPolicy * p = UMLApp::app()->getCommonPolicy();
     QString endLine = p->getNewLineEndingChars();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/rubycodeaccessormethod.cpp #646767:646768
@@ -45,8 +45,8 @@
     setType(type);
 
     // lets use full-blown comment
-    setComment(new RubyCodeDocumentation((RubyClassifierCodeDocument*)field->getParentDocument()));
-
+    RubyClassifierCodeDocument *rccd = dynamic_cast<RubyClassifierCodeDocument*>(field->getParentDocument());
+    setComment(new RubyCodeDocumentation(rccd));
 }
 
 RubyCodeAccessorMethod::~RubyCodeAccessorMethod ( ) { }
@@ -77,7 +77,7 @@
 {
 
     CodeClassField * parentField = getParentClassField();
-    RubyCodeClassField * rubyfield = (RubyCodeClassField*)parentField;
+    RubyCodeClassField * rubyfield = dynamic_cast<RubyCodeClassField*>(parentField);
     QString fieldName = rubyfield->getFieldName();
     QString endLine = UMLApp::app()->getCommonPolicy()->getNewLineEndingChars();
 
@@ -86,7 +86,6 @@
     case CodeAccessorMethod::ADD:
         {
             int maxOccurs = rubyfield->maximumListOccurances();
-            RubyClassifierCodeDocument * rubydoc = (RubyClassifierCodeDocument*) rubyfield->getParentDocument();
             QString fieldType = rubyfield->getTypeName();
             QString indent = getIndentation();
             if(maxOccurs > 0)
@@ -108,7 +107,7 @@
     case CodeAccessorMethod::REMOVE:
         {
             int minOccurs = rubyfield->minimumListOccurances();
-            RubyClassifierCodeDocument * rubydoc = (RubyClassifierCodeDocument*) rubyfield->getParentDocument();
+            RubyClassifierCodeDocument * rubydoc = dynamic_cast<RubyClassifierCodeDocument*>(rubyfield->getParentDocument());
             QString fieldType = rubyfield->getTypeName();
             QString indent = getIndentation();
 
@@ -137,8 +136,8 @@
 void RubyCodeAccessorMethod::updateMethodDeclaration()
 {
 
-    RubyCodeClassField * rubyfield = (RubyCodeClassField*) getParentClassField();
-    RubyClassifierCodeDocument * rubydoc = (RubyClassifierCodeDocument*) rubyfield->getParentDocument();
+    RubyCodeClassField * rubyfield = dynamic_cast<RubyCodeClassField*>(getParentClassField());
+    RubyClassifierCodeDocument * rubydoc = dynamic_cast<RubyClassifierCodeDocument*>(rubyfield->getParentDocument());
 
     // gather defs
     CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/rubycodeclassfielddeclarationblock.cpp #646767:646768
@@ -47,8 +47,8 @@
 
     CodeClassField * cf = getParentClassField();
     ClassifierCodeDocument * doc = cf->getParentDocument();
-    RubyCodeClassField * rcf = (RubyCodeClassField*) cf;
-    RubyClassifierCodeDocument* rdoc = (RubyClassifierCodeDocument*) doc;
+    RubyCodeClassField * rcf = dynamic_cast<RubyCodeClassField*>(cf);
+    RubyClassifierCodeDocument* rdoc = dynamic_cast<RubyClassifierCodeDocument*>(doc);
     CodeGenerationPolicy * p = UMLApp::app()->getCommonPolicy();
     CodeGenerationPolicy::ScopePolicy scopePolicy = p->getAssociationFieldScope();
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/rubycodeoperation.cpp #646767:646768
@@ -28,7 +28,7 @@
 //
 
 RubyCodeOperation::RubyCodeOperation ( RubyClassifierCodeDocument * doc, UMLOperation *parent, const QString & body, const QString & comment )
-        : CodeOperation ((ClassifierCodeDocument*)doc, parent, body, comment)
+        : CodeOperation (doc, parent, body, comment)
 {
     // lets not go with the default comment and instead use
     // full-blown ruby documentation object instead
@@ -211,7 +211,7 @@
 }
 
 int RubyCodeOperation::lastEditableLine() {
-    ClassifierCodeDocument * doc = (ClassifierCodeDocument*)getParentDocument();
+    ClassifierCodeDocument * doc = dynamic_cast<ClassifierCodeDocument*>(getParentDocument());
     if(doc->parentIsInterface())
         return -1; // very last line is NOT editable as its a one-line declaration w/ no body in
     // an interface.
Comment 16 Oliver Kellogg 2007-03-26 18:55:47 UTC
Same pattern as described in comment #12. Using dynamic_cast instead of
C style pointer cast reveals that the type is not what was expected.
In this case, the
   CPPCodeClassField * hcppcf = dynamic_cast<CPPCodeClassField*>(cf);
in CPPHeaderCodeClassFieldDeclarationBlock::updateContent() yields NULL
for the hcppcf:

#0  0x082e9a40 in CPPHeaderCodeClassFieldDeclarationBlock::updateContent
    (this=0x89c8058)
    at codegenerators/cppheadercodeclassfielddeclarationblock.cpp:63
#1  0x082e96fd in CPPHeaderCodeClassFieldDeclarationBlock (this=0x89c8058,
    parent=0x89f08b0)
    at codegenerators/cppheadercodeclassfielddeclarationblock.cpp:28
#2  0x082c3283 in CodeGenFactory::newDeclarationCodeBlock (cd=0x89c7c20,
    cf=0x89f08b0)
    at codegenerators/codegenfactory.cpp:316
#3  0x08152881 in CodeClassField::initFields (this=0x89f08b0, inConstructor=true)
    at codeclassfield.cpp:598
#4  0x08150a3e in CodeClassField (this=0x89f08b0, doc=0x89c7c20,
    attrib=0x8954870)
    at codeclassfield.cpp:49
#5  0x082d92aa in CPPCodeClassField (this=0x89f08b0, parentDoc=0x89c7c20,
    attrib=0x8954870)
    at codegenerators/cppcodeclassfield.cpp:43
#6  0x082c2ec1 in CodeGenFactory::newCodeClassField (ccd=0x89c7c20,
    at=0x8954870)
    at codegenerators/codegenfactory.cpp:234
#7  0x08147e7b in ClassifierCodeDocument::initCodeClassFields (this=0x89c7c20)
    at classifiercodedocument.cpp:497
#8  0x082d7bfe in CPPCodeGenerator::newHeaderClassifierCodeDocument
    (this=0x89e7200, classifier=0x8954720)
    at codegenerators/cppcodegenerator.cpp:256
#9  0x082d7d2b in CPPCodeGenerator::initFromParentDocument (this=0x89e7200)
    at codegenerators/cppcodegenerator.cpp:293
#10 0x082c287f in CodeGenFactory::createObject (pl=pl_Cpp)
    at codegenerators/codegenfactory.cpp:176
#11 0x081b718d in UMLApp::setGenerator (this=0x84cdc38, pl=pl_Cpp)
    at uml.cpp:1237
#12 0x081c6e48 in UMLDoc::loadExtensionsFromXMI (this=0x84dd5f0,
    node=@0xbfffe970)
    at umldoc.cpp:1782
#13 0x081c4910 in UMLDoc::loadFromXMI (this=0x84dd5f0, file=@0xbfffeb90,
    encode=1)
    at umldoc.cpp:1474
#14 0x081beb9c in UMLDoc::openDocument (this=0x84dd5f0, url=@0xbfffec80)
    at umldoc.cpp:481
Comment 17 Oliver Kellogg 2007-03-30 06:28:24 UTC
SVN commit 647978 by okellogg:

initFields(): Move invocation of  CodeGenFactory::newDeclarationCodeBlock() to
 finishInitialization(). If inConstructor is true then no dispatching to the
 CPPCodeClassField takes place.
BUG:126262


 M  +1 -0      ChangeLog  
 M  +2 -1      umbrello/codeclassfield.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #647977:647978
@@ -10,6 +10,7 @@
 * Operations of the Interface are not implemented in the class automatically
   (111593)
 * Relationships for entities do not live outside of the diagram (125146)
+* Crashes while loading file (Advanced Code Generators enabled) (126262)
 * Multiplicity labels often are placed incorrectly (127628)
 * Crash on adding operation to class with Advanced Code Generators enabled
   (131528)
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeclassfield.cpp #647977:647978
@@ -595,7 +595,7 @@
 
     m_writeOutMethods = false;
     m_listClassName = QString ("");
-    m_declCodeBlock = CodeGenFactory::newDeclarationCodeBlock(getParentDocument(), this);
+    m_declCodeBlock = NULL;
 
     m_methodVector.setAutoDelete(false);
     // m_methodMap = new QMap<CodeAccessorMethod::AccessorType, CodeAccessorMethod *>;
@@ -605,6 +605,7 @@
 }
 
 void CodeClassField::finishInitialization() {
+    m_declCodeBlock = CodeGenFactory::newDeclarationCodeBlock(getParentDocument(), this);
     initAccessorMethods();
     updateContent();
 
Comment 18 Oliver Kellogg 2007-04-07 04:10:41 UTC
Still crashes when Undo is enabled:

#4  0x416a9689 in free () from /lib/tls/libc.so.6
#5  0x415f9c61 in operator delete () from /usr/lib/libstdc++.so.5
#6  0x415f9cbd in operator delete[] () from /usr/lib/libstdc++.so.5
#7  0x4114b9b8 in QStringData::deleteSelf ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#8  0x08121cc7 in ~QString (this=0xbfffe200)
    at /usr/lib/qt3/include/qstring.h:848
#9  0x08148cd1 in ClassifierCodeDocument::findCodeClassFieldTextBlockByTag (
    this=0x89d5678, tag=@0xbfffe320)
    at classifiercodedocument.cpp:728
#10 0x081746aa in HierarchicalCodeBlock::findCodeClassFieldTextBlockByTag (
    this=0x89d5b48, tag=@0xbfffe320)
    at hierarchicalcodeblock.cpp:362
#11 0x0815dded in CodeGenObjectWithTextBlocks::loadChildTextBlocksFromNode (
    this=0x89d5b6c, root=@0xbfffe500)
    at codegenobjectwithtextblocks.cpp:414
#12 0x0815db4b in CodeGenObjectWithTextBlocks::setAttributesFromNode (
    this=0x89d5b6c, root=@0xbfffe500)
    at codegenobjectwithtextblocks.cpp:369
#13 0x08174166 in HierarchicalCodeBlock::setAttributesFromNode (
    this=0x89d5b48, root=@0xbfffe500)
    at hierarchicalcodeblock.cpp:286
#14 0x08173f96 in HierarchicalCodeBlock::loadFromXMI (this=0x89d5b48,
    root=@0xbfffe500)
    at hierarchicalcodeblock.cpp:265
#15 0x0815e1ab in CodeGenObjectWithTextBlocks::loadChildTextBlocksFromNode (
    this=0x89d56a0, root=@0xbfffe720)
    at codegenobjectwithtextblocks.cpp:449
#16 0x0815db4b in CodeGenObjectWithTextBlocks::setAttributesFromNode (
    this=0x89d56a0, root=@0xbfffe720)
    at codegenobjectwithtextblocks.cpp:369
#17 0x08155a9c in CodeDocument::setAttributesFromNode (this=0x89d5678,
    root=@0xbfffe720)
    at codedocument.cpp:410
#18 0x081482f1 in ClassifierCodeDocument::setAttributesFromNode (
    this=0x89d5678, elem=@0xbfffe720)
    at classifiercodedocument.cpp:593
#19 0x081489f6 in ClassifierCodeDocument::loadFromXMI (this=0x89d5678,
    root=@0xbfffe720)
    at classifiercodedocument.cpp:685
#20 0x08159df6 in CodeGenerator::loadFromXMI (this=0x89e9a20,
    qElement=@0xbfffe7e0)
    at codegenerator.cpp:205
#21 0x081c6e75 in UMLDoc::loadExtensionsFromXMI (this=0x84dd670,
    node=@0xbfffea10)
    at umldoc.cpp:1783
#22 0x081c4918 in UMLDoc::loadFromXMI (this=0x84dd670, file=@0xbfffec30,
    encode=1)
    at umldoc.cpp:1474
#23 0x081beba4 in UMLDoc::openDocument (this=0x84dd670, url=@0xbfffece0)
    at umldoc.cpp:481
#24 0x081b32cf in UMLApp::openDocumentFile (this=0x84cdcc8, url=@0xbfffece0)
    at uml.cpp:481
#25 0x08187584 in initDocument (args=0x83e3318, cfg=0x849e020)
    at main.cpp:178
Comment 19 Oliver Kellogg 2007-04-14 22:38:52 UTC
SVN commit 654003 by okellogg:

readOptionState(): Reinstall barrier against advanced code generators.
Further use of the newcodegen config has revealed that it's still unstable.
In order to work on this, add -DWORK_ON_BUG_126262 to the CFLAGS in the
Makefile.
CCBUG:126262


 M  +4 -0      uml.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/uml.cpp #654002:654003
@@ -1097,7 +1097,11 @@
     Settings::OptionState& optionState = Settings::getOptionState();
     optionState.generalState.undo = m_config -> readBoolEntry( "undo", true );
     optionState.generalState.tabdiagrams = m_config -> readBoolEntry("tabdiagrams", false);
+#if defined (WORK_ON_BUG_126262)
     optionState.generalState.newcodegen = m_config -> readBoolEntry("newcodegen", false);
+#else
+    optionState.generalState.newcodegen = false;
+#endif
     optionState.generalState.angularlines = m_config->readBoolEntry("angularlines", false);
     optionState.generalState.autosave = m_config -> readBoolEntry( "autosave", true );
     optionState.generalState.time = m_config -> readNumEntry( "time", 0 ); //old autosavetime value kept for compatibility
Comment 20 Oliver Kellogg 2007-07-09 18:26:13 UTC
Created attachment 21100 [details]
valgrind log loading attachment 15779 [details]

AFAICT the trace stays the same, even after Sharan's cleanup on trunk
(r685447).
Comment 21 Oliver Kellogg 2007-08-29 22:50:09 UTC
The XMI file itself may be corrupted.
For a clean start, I created a new report. See bug 149357.