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

Oliver Kellogg okellogg at users.sourceforge.net
Wed Sep 13 21:33:40 UTC 2006


SVN commit 583970 by okellogg:

setPackage(): Allow UMLDoc::findUMLObject() to return any type of container
(Uml::ot_{Package,Folder,Component}.)


 M  +11 -7     umlobject.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlobject.cpp #583969:583970
@@ -306,16 +306,20 @@
     UMLObject *pkgObj = NULL;
     if (!_name.isEmpty()) {
         UMLDoc* umldoc = UMLApp::app()->getDocument();
-        if (umldoc == NULL) {
-            kdError() << "UMLObject::setPackage: cannot set package name on "
-            << m_Name << endl;
-            return;
-        }
-        pkgObj = umldoc->findUMLObject(_name, Uml::ot_Package);
+        pkgObj = umldoc->findUMLObject(_name);
         if (pkgObj == NULL) {
             kdDebug() << "UMLObject::setPackage: creating UMLPackage "
-            << _name << " for " << m_Name << endl;
+                << _name << " for " << m_Name << endl;
             pkgObj = Import_Utils::createUMLObject(Uml::ot_Package, _name);
+        } else {
+            const Uml::Object_Type ot = pkgObj->getBaseType();
+            if (ot != Uml::ot_Package && ot != Uml::ot_Folder && ot != Uml::ot_Component) {
+                kdError() << "UMLObject::setPackage(" << m_Name << "): "
+                    << "existing " << _name << " is not a container" << endl;
+                // This should not happen - if it does, there may be further problems.
+                // A container name should not overlap with another name in the same scope.
+                pkgObj = Import_Utils::createUMLObject(Uml::ot_Package, _name);
+            }
         }
     }
     setUMLPackage( static_cast<UMLPackage *>(pkgObj) );




More information about the umbrello-devel mailing list