[Uml-devel] KDE/kdesdk/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Wed Aug 1 22:37:49 UTC 2007


SVN commit 695359 by okellogg:

merge r690372:692032 from branches/KDE/3.5

 M  +1 -0      ChangeLog  
 M  +1 -0      umbrello/model_utils.cpp  
 M  +3 -5      umbrello/umldoc.cpp  
 M  +47 -26    umbrello/umlobject.cpp  
 M  +8 -0      umbrello/umlobject.h  


--- trunk/KDE/kdesdk/umbrello/ChangeLog #695358:695359
@@ -9,6 +9,7 @@
 * Crash when changing the association type to containment (147202)
 * Moving component on diagram results in absurd shape of self-association (147810)
 * Crash when changing the attribute name (147919)
+* Reads XMI exported by version 1.5 but crashes when rereading after saving (147988)
 
 Version 1.5.71
 
--- trunk/KDE/kdesdk/umbrello/umbrello/model_utils.cpp #695358:695359
@@ -290,6 +290,7 @@
                    Uml::tagEq(tag, "isActive") ||
                    Uml::tagEq(tag, "namespace") ||
                    Uml::tagEq(tag, "ownerScope") ||
+                   Uml::tagEq(tag, "ModelElement.stereotype") ||
                    Uml::tagEq(tag, "GeneralizableElement.generalization") ||
                    Uml::tagEq(tag, "specialization") ||   //NYI
                    Uml::tagEq(tag, "clientDependency") || //NYI
--- trunk/KDE/kdesdk/umbrello/umbrello/umldoc.cpp #695358:695359
@@ -1642,16 +1642,14 @@
         // From here on, it's support for stereotypes, pre 1.5.5 versions, and foreign files
         if (tagEq(type, "Namespace.ownedElement") ||
                 tagEq(type, "Namespace.contents") ||
-                tagEq(type, "Model") || tagEq(type, "ModelElement.stereotype")) {
+                tagEq(type, "Model")) {
             //CHECK: Umbrello currently assumes that nested elements
             // are ownedElements anyway.
             // Therefore the <UML:Namespace.ownedElement> tag is of no
             // significance.
             if( !loadUMLObjectsFromXMI( tempElement ) ) {
-                if (! tagEq(type, "ModelElement.stereotype")) {  // not yet implemented
-                    kWarning() << "failed load on " << type << endl;
-                    return false;
-                }
+                kWarning() << "failed load on " << type << endl;
+                return false;
             }
             continue;
         }
--- trunk/KDE/kdesdk/umbrello/umbrello/umlobject.cpp #695358:695359
@@ -565,6 +565,36 @@
     return true;
 }
 
+bool UMLObject::loadStereotype(QDomElement & element) {
+    QString tag = element.tagName();
+    if (!Uml::tagEq(tag, "stereotype"))
+        return false;
+    QString stereo = element.attribute("xmi.value", "");
+    if (stereo.isEmpty() && element.hasChildNodes()) {
+        /* like so:
+         <UML:ModelElement.stereotype>
+           <UML:Stereotype xmi.idref = '07CD'/>
+         </UML:ModelElement.stereotype>
+         */
+        QDomNode stereoNode = element.firstChild();
+        QDomElement stereoElem = stereoNode.toElement();
+        tag = stereoElem.tagName();
+        if (Uml::tagEq(tag, "Stereotype")) {
+            stereo = stereoElem.attribute("xmi.idref", "");
+        }
+    }
+    if (stereo.isEmpty())
+        return false;
+    Uml::IDType stereoID = STR2ID(stereo);
+    UMLDoc *pDoc = UMLApp::app()->getDocument();
+    m_pStereotype = pDoc->findStereotypeById(stereoID);
+    if (m_pStereotype)
+        m_pStereotype->incrRefCount();
+    else
+        m_SecondaryId = stereo;  // leave it to resolveRef()
+    return true;
+}
+
 bool UMLObject::loadFromXMI( QDomElement & element) {
     UMLDoc* umldoc = UMLApp::app()->getDocument();
     if (umldoc == NULL) {
@@ -587,6 +617,18 @@
         }
     } else {
         m_nId = STR2ID(id);
+        if (m_BaseType == Uml::ot_Role) {
+            // Some older Umbrello versions had a problem with xmi.id's
+            // of other objects being reused for the UMLRole, see e.g.
+            // attachment 21179 at http://bugs.kde.org/147988 .
+            // If the xmi.id is already being used then we generate a new one.
+            UMLObject *o = umldoc->findObjectById(m_nId);
+            if (o) {
+                kDebug() << "loadFromXMI(UMLRole): id " << id
+                    << " is already in use, generating a new one." << endl;
+                m_nId = UniqueID::gen();
+            }
+        }
     }
 
     if (element.hasAttribute("documentation"))  // for bkwd compat.
@@ -669,11 +711,11 @@
                 if (vis.isEmpty())
                     vis = elem.text();
                 if (vis == "private" || vis == "private_vis")
-                      m_Vis = Uml::Visibility::Private;
+                    m_Vis = Uml::Visibility::Private;
                 else if (vis == "protected" || vis == "protected_vis")
-                  m_Vis = Uml::Visibility::Protected;
+                    m_Vis = Uml::Visibility::Protected;
                 else if (vis == "implementation")
-                  m_Vis = Uml::Visibility::Implementation;
+                    m_Vis = Uml::Visibility::Implementation;
             } else if (Uml::tagEq(tag, "isAbstract")) {
                 QString isAbstract = elem.attribute("xmi.value", "");
                 if (isAbstract.isEmpty())
@@ -684,29 +726,8 @@
                 if (ownerScope.isEmpty())
                     ownerScope = elem.text();
                 m_bStatic = (ownerScope == "classifier");
-            } else if (Uml::tagEq(tag, "stereotype")) {
-                QString stereo = elem.attribute("xmi.value", "");
-                if (stereo.isEmpty() && elem.hasChildNodes()) {
-                    /* like so:
-                     <UML:ModelElement.stereotype>
-                       <UML:Stereotype xmi.idref = '07CD'/>
-                     </UML:ModelElement.stereotype>
-                     */
-                    QDomNode stereoNode = elem.firstChild();
-                    QDomElement stereoElem = stereoNode.toElement();
-                    tag = stereoElem.tagName();
-                    if (Uml::tagEq(tag, "Stereotype")) {
-                        stereo = stereoElem.attribute("xmi.idref", "");
-                    }
-                }
-                if (! stereo.isEmpty()) {
-                    Uml::IDType stereoID = STR2ID(stereo);
-                    m_pStereotype = umldoc->findStereotypeById(stereoID);
-                    if (m_pStereotype)
-                        m_pStereotype->incrRefCount();
-                    else
-                        m_SecondaryId = stereo;  // leave it to resolveRef()
-                }
+            } else {
+                loadStereotype(elem);
             }
             node = node.nextSibling();
             if (node.isComment())
--- trunk/KDE/kdesdk/umbrello/umbrello/umlobject.h #695358:695359
@@ -318,6 +318,14 @@
     virtual bool loadFromXMI( QDomElement & element );
 
     /**
+     * Analyzes the given QDomElement for a reference to a stereotype.
+     *
+     * @param element    QDomElement to analyze.
+     * @return        True if a stereotype reference was found, else false.
+     */
+    bool loadStereotype(QDomElement & element);
+
+    /**
      * Returns true if this UMLObject has classifier scope,
      * otherwise false (the default).
      */




More information about the umbrello-devel mailing list