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

Oliver Kellogg okellogg at users.sourceforge.net
Fri May 4 21:22:39 UTC 2007


SVN commit 661210 by okellogg:

It seems that a previous version of Umbrello could create XMI files where
some model objects were missing. This is a workaround so that Umbrello at least
doesn't crash on loading such a file:

validateObjType(): Pass in the UMLObject* by reference. Add a Uml::IDType arg.
When the UMLObject* is NULL then create a new object with an artificial name,
"LOST_" followed by the id, and set its ID to the arg passed in.

This means that the user needs to manually rename the LOST_ items after loading
a corrupted file. Sorry.

BUG:145035


 M  +1 -0      ChangeLog  
 M  +25 -14    umbrello/widget_factory.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #661209:661210
@@ -35,6 +35,7 @@
 * No synchronisation of comments when round-tripping (144346)
 * Crash when loading xmi with actor as object of sequence diagram (144442)
 * ActionScript/JavaScript association code generation error (144788)
+* Segmentation fault on loading corrupted file (145035)
 
 Version 1.5.61
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/widget_factory.cpp #661209:661210
@@ -19,6 +19,7 @@
 #include "uml.h"
 #include "umldoc.h"
 #include "umlview.h"
+#include "object_factory.h"
 #include "floatingtextwidget.h"
 #include "classifierwidget.h"
 #include "classifier.h"
@@ -138,9 +139,19 @@
     return newWidget;
 }
 
-bool validateObjType(Uml::Object_Type expected, UMLObject *o) {
-    if (o == NULL)
-        return true;  // cannot validate
+bool validateObjType(Uml::Object_Type expected, UMLObject* &o, Uml::IDType id) {
+    if (o == NULL) {
+        kDebug() << "Widget_Factory::validateObjType: creating new object of type "
+                 << expected << endl;
+        QString artificialName = "LOST_" + ID2STR(id);
+        o = Object_Factory::createUMLObject(expected, artificialName, NULL, false);
+        if (o == NULL)
+            return false;
+        o->setID(id);
+        UMLPackage *parentPkg = o->getUMLPackage();
+        parentPkg->addObject(o);
+        return true;
+    }
     Uml::Object_Type actual = o->getBaseType();
     if (actual == expected)
         return true;
@@ -186,40 +197,40 @@
 
         if (tag == "actorwidget"
                 || tag == "UML:ActorWidget") {           // for bkwd compatibility
-            if (validateObjType(Uml::ot_Actor, o))
+            if (validateObjType(Uml::ot_Actor, o, id))
                 widget = new ActorWidget(view, static_cast<UMLActor*>(o));
         } else if (tag == "usecasewidget"
                    || tag == "UML:UseCaseWidget") {  // for bkwd compatibility
-            if (validateObjType(Uml::ot_UseCase, o))
+            if (validateObjType(Uml::ot_UseCase, o, id))
                 widget = new UseCaseWidget(view, static_cast<UMLUseCase*>(o));
         } else if (tag == "classwidget"
                    || tag == "UML:ClassWidget"       // for bkwd compatibility
                    || tag == "UML:ConceptWidget") {  // for bkwd compatibility
-            if (validateObjType(Uml::ot_Class, o))
+            if (validateObjType(Uml::ot_Class, o, id))
                 widget = new ClassifierWidget(view, static_cast<UMLClassifier*>(o));
         } else if (tag == "packagewidget") {
-            if (validateObjType(Uml::ot_Package, o))
+            if (validateObjType(Uml::ot_Package, o, id))
                 widget = new PackageWidget(view, static_cast<UMLPackage*>(o));
         } else if (tag == "componentwidget") {
-            if (validateObjType(Uml::ot_Component, o))
+            if (validateObjType(Uml::ot_Component, o, id))
                 widget = new ComponentWidget(view, static_cast<UMLComponent*>(o));
         } else if (tag == "nodewidget") {
-            if (validateObjType(Uml::ot_Node, o))
+            if (validateObjType(Uml::ot_Node, o, id))
                 widget = new NodeWidget(view, static_cast<UMLNode*>(o));
         } else if (tag == "artifactwidget") {
-            if (validateObjType(Uml::ot_Artifact, o))
+            if (validateObjType(Uml::ot_Artifact, o, id))
                 widget = new ArtifactWidget(view, static_cast<UMLArtifact*>(o));
         } else if (tag == "interfacewidget") {
-            if (validateObjType(Uml::ot_Interface, o))
+            if (validateObjType(Uml::ot_Interface, o, id))
                 widget = new ClassifierWidget(view, static_cast<UMLClassifier*>(o));
         } else if (tag == "datatypewidget") {
-            if (validateObjType(Uml::ot_Datatype, o))
+            if (validateObjType(Uml::ot_Datatype, o, id))
                 widget = new DatatypeWidget(view, static_cast<UMLClassifier*>(o));
         } else if (tag == "enumwidget") {
-            if (validateObjType(Uml::ot_Enum, o))
+            if (validateObjType(Uml::ot_Enum, o, id))
                 widget = new EnumWidget(view, static_cast<UMLEnum*>(o));
         } else if (tag == "entitywidget") {
-            if (validateObjType(Uml::ot_Entity, o))
+            if (validateObjType(Uml::ot_Entity, o, id))
                 widget = new EntityWidget(view, static_cast<UMLEntity*>(o));
         } else if (tag == "objectwidget"
                    || tag == "UML:ObjectWidget") {  // for bkwd compatibility




More information about the umbrello-devel mailing list