Bug 147988 - Reads XMI exported by version 1.5, but crashes when rereading after saving in Umbrello 1.5.7
Summary: Reads XMI exported by version 1.5, but crashes when rereading after saving in...
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR crash
Target Milestone: ---
Assignee: Oliver Kellogg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-18 20:19 UTC by Soren Roug
Modified: 2007-07-21 19:36 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
XMI file created by version 1.5 (377.74 KB, application/octet-stream)
2007-07-18 20:21 UTC, Soren Roug
Details
corrected XMI file (377.96 KB, application/x-uml)
2007-07-19 00:23 UTC, Oliver Kellogg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Soren Roug 2007-07-18 20:19:34 UTC
Version:           1.5.7 (using KDE KDE 3.5.7)
Installed from:    Fedora RPMs
OS:                Linux

I have this old XMI file from January 2006, written last time by Umbrello 1.5. Umbrello 1.5.7 can read it, but when I save the file from Umbrello 1.5.7 and loads it into Umbrello 1.5.7 again, Umbrello crashes. The thing prevents me from continuing my work. All I really want is to have the XMI file readable by 1.5.7 again.

Backtrace:
(no debugging symbols found)
[KCrash handler]
#6  0x008c719f in main_arena () from /lib/libc.so.6
#7  0x0816d01e in Model_Utils::findObjectInList ()
#8  0x0817e980 in UMLPackage::findObjectById ()
#9  0x081a0a16 in UMLDoc::findObjectById ()
#10 0x0814f377 in UMLFolder::load ()
#11 0x0814ef18 in UMLFolder::load ()
#12 0x081c86b8 in UMLObject::loadFromXMI ()
#13 0x081ae9ca in UMLDoc::loadUMLObjectsFromXMI ()
#14 0x081ae6d4 in UMLDoc::loadUMLObjectsFromXMI ()
#15 0x081b00af in UMLDoc::loadFromXMI ()
#16 0x081aa08a in UMLDoc::openDocument ()
#17 0x081953dd in UMLApp::openDocumentFile ()
#18 0x08167190 in initDocument ()
#19 0x08167750 in main ()
Comment 1 Soren Roug 2007-07-18 20:21:59 UTC
Created attachment 21179 [details]
XMI file created by version 1.5

Open this file in Umbrello 1.5.7, click save, then open it again. It make
Umbrello crash.
Comment 2 Oliver Kellogg 2007-07-18 22:33:59 UTC
Confirm with SVN branches/KDE/3.5 of today.
Comment 3 Oliver Kellogg 2007-07-19 00:23:41 UTC
Created attachment 21182 [details]
corrected XMI file

The problem was that apparently the older version generated conflicting
xmi.id's for <UML:Association.connection> (i.e. UMLRole) items.
I simply prefixed thse xmi.id's with "r" to make them unique.
Comment 4 Oliver Kellogg 2007-07-19 00:24:06 UTC
The file saved by 1.5.71 now loads but there may still be more duplicated
xmi.id's, please check.
Comment 5 Oliver Kellogg 2007-07-21 19:36:15 UTC
SVN commit 690647 by okellogg:

loadFromXMI(): If the xmi.id of an UMLRole is already in use then generate a new one.
CCBUG:147988


 M  +1 -0      ChangeLog  
 M  +15 -3     umbrello/umlobject.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #690646:690647
@@ -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
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlobject.cpp #690646:690647
@@ -565,6 +565,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 [details] 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.
@@ -647,11 +659,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())