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

Oliver Kellogg okellogg at users.sourceforge.net
Sat Feb 11 23:08:10 UTC 2012


SVN commit 1279514 by okellogg:

Apply attachment 68501 :

umbrello/stereotype.h
- In class doc, mention that umlPackage() returns NULL for a stereotype,
  and explain why this is so.

umbrello/umlobject.cpp
- setUMLPackage(): Allow setting m_pUMLPackage to NULL (due to stereotypes.)

umbrello/umldoc.cpp
- loadUMLObjectsFromXMI(): Exclude stereotypes from the guessContainer()
  call in order to allow pObject->umlPackage() to return NULL.

CCBUG:283744


 M  +6 -0      stereotype.h  
 M  +3 -1      umldoc.cpp  
 M  +6 -0      umlobject.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/stereotype.h #1279513:1279514
@@ -26,6 +26,12 @@
  * i.e. client code must take care to call incrRefCount() and
  * decrRefCount() as appropriate.
  *
+ * The one and only owner of all stereotypes is the UMLDoc, and the
+ * ownership is specially managed (umlPackage() returns NULL for a
+ * UMLStereotype.) The reason for this special treatment is that
+ * class UMLDoc does not inherit from class UMLPackage, and therefore
+ * setUMLPackage() cannot be used for stereotypes.
+ *
  * @short Sets up stereotype information.
  * @author Jonathan Riddell
  * @author Oliver Kellogg
--- trunk/KDE/kdesdk/umbrello/umbrello/umldoc.cpp #1279513:1279514
@@ -2136,6 +2136,7 @@
         UMLObject::ObjectType ot = pObject->baseType();
         // Set the parent root folder.
         UMLPackage *pkg = 0;
+        if (ot != UMLObject::ot_Stereotype) {
         if (ot == UMLObject::ot_Datatype) {
             pkg = m_datatypeRoot;
         } else {
@@ -2149,6 +2150,7 @@
                 pkg = m_root[Uml::ModelType::Logical];
             }
         }
+        }
         pObject->setUMLPackage(pkg);
 
         bool status = pObject->loadFromXMI( tempElement );
@@ -2178,7 +2180,7 @@
         if (pkg) {
             pkg->addObject(pObject);
         }
-        else {
+        else if (ot != UMLObject::ot_Stereotype) {
             uError() << "Package is NULL for " << pObject->name();
             return false;
         }
--- trunk/KDE/kdesdk/umbrello/umbrello/umlobject.cpp #1279513:1279514
@@ -537,6 +537,12 @@
         return false;
     }
 
+    if (pPkg == NULL) {
+        // Allow setting to NULL for stereotypes
+        m_pUMLPackage = pPkg;
+        return true;
+    }
+
     if (pPkg->umlPackage() == this) {
         uDebug() << "setting parent to an object of which I'm already the parent is not allowed";
         return false;




More information about the umbrello-devel mailing list