Bug 371495 - Lost class and interface names when open the project
Summary: Lost class and interface names when open the project
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Microsoft Windows Microsoft Windows
: NOR critical
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-22 19:58 UTC by Hamid Sahraiee
Modified: 2016-11-03 08:58 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.20.3 (KDE Applications 16.08.03)


Attachments
the Umbrello project file that LOST class names (60.36 KB, application/xml)
2016-10-24 20:21 UTC, Hamid Sahraiee
Details
Corrected file (54.22 KB, text/x-xmi)
2016-10-26 18:23 UTC, Ralf Habacker
Details
Minimal testcase (10.12 KB, application/xml)
2016-10-27 06:33 UTC, Ralf Habacker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hamid Sahraiee 2016-10-22 19:58:47 UTC
after save the project and Quite it and again open the Umbrello and through file-> Open recent open my project some of the class and Interface names Lost and don't show them in the correct folder.
but when open their properties the name in general setting show correctly and when hit OK button  the panel, it fix the class names but don't move it to the correct folder.

umbrello version : 2.20.2

Good Luck ;)

Reproducible: Always
Comment 1 Ralf Habacker 2016-10-24 14:29:22 UTC
> Open recent open my project some of the class and Interface names Lost 
You are referring to the icons in the tree view ? 
> and don't show them in the correct folder.
If possible it would be nice to get the related xmi file to be able to see if the file is somehow corrupt or something else if wrong.
Comment 2 Hamid Sahraiee 2016-10-24 20:19:43 UTC
(In reply to Ralf Habacker from comment #1)
> > Open recent open my project some of the class and Interface names Lost 
> You are referring to the icons in the tree view ? 
> > and don't show them in the correct folder.
> If possible it would be nice to get the related xmi file to be able to see
> if the file is somehow corrupt or something else if wrong.



it's because I  open the old project (Umbrello 1.18.x) in the new version.
I solved by delete that lost class and rewrite them again in new version. this fixed my problem .
Comment 3 Hamid Sahraiee 2016-10-24 20:21:35 UTC
Created attachment 101756 [details]
the Umbrello project file that LOST class names
Comment 4 Hamid Sahraiee 2016-10-24 20:27:33 UTC
(In reply to Hamid Sahraiee from comment #2)
> (In reply to Ralf Habacker from comment #1)
> > > Open recent open my project some of the class and Interface names Lost 
> > You are referring to the icons in the tree view ? 
> > > and don't show them in the correct folder.
> > If possible it would be nice to get the related xmi file to be able to see
> > if the file is somehow corrupt or something else if wrong.
> 
> 
> 
> it's because I  open the old project (Umbrello 1.18.x) in the new version.
> I solved by delete that lost class and rewrite them again in new version.
> this fixed my problem .

Sorry for mistake :: Old project file  (Umbrello 2.18.x) 

You are referring to the icons in the tree view ? 
it show icons in the root of the <Logical View> . but they have special package name.
I attach my project file.

Good Luck.
Comment 5 Ralf Habacker 2016-10-24 22:34:41 UTC
(In reply to Hamid Sahraiee from comment #4)
> it show icons in the root of the <Logical View> . but they have special
> package name.
> I attach my project file.
Thanks, this helps to identify the root cause. 

The root cause looks to be a problem of resolving forward declared uml objects. On loading the file the objects named LOST_... are referenced in a diagram widget, but are later defined in the file.
Comment 6 Ralf Habacker 2016-10-25 17:24:01 UTC
(In reply to Ralf Habacker from comment #5)
> The root cause looks to be a problem of resolving forward declared uml
> objects. On loading the file the objects named LOST_... are referenced in a
> diagram widget, but are later defined in the file.
To fix this issue I see two possible solutions: 
1. Complete support for forward declaring uml object 
2. Refactor loading of xmi files to use two passes: In the first pass load *all* uml objects and in the second pass load the diagrams.
Comment 7 Ralf Habacker 2016-10-26 18:23:04 UTC
Created attachment 101804 [details]
Corrected file

The file you provided contains some corruptions. I fixed them using an experimental patch which loads the diagrams after uml objects to avoid lost objects. The remaining issues I fixed by removing the listview related entries in the xmi file except the diagram entry. The remaining objects in the tree view are restored on loading the xmi file.
Comment 8 Ralf Habacker 2016-10-27 06:33:12 UTC
Created attachment 101820 [details]
Minimal testcase

The appended  minimal testcase shows the issue with umbrello 2.18.x.
Comment 9 Ralf Habacker 2016-10-27 06:38:39 UTC
(In reply to Ralf Habacker from comment #8)
> The appended  minimal testcase shows the issue with umbrello 2.18.x.

The issue happens when diagrams are in a folder while the diagram contains classes from another folder created *after* the folder containing the diagram.
Comment 10 Ralf Habacker 2016-10-27 07:01:40 UTC
(In reply to Ralf Habacker from comment #9)
> The issue happens when diagrams are in a folder while the diagram contains
> classes from another folder created *after* the folder containing the
> diagram.

A possible workaround is to move the related class diagram into a folder that has been created after the folder containing the referenced classes. After moving all elements from the original folder into the new one the original folder can be deleted and the new folder can be renamed to the original one.
Comment 11 Ralf Habacker 2016-10-27 07:09:29 UTC
(In reply to Ralf Habacker from comment #10)
Another fix is to place classes into packages not into folder.
Comment 12 Ralf Habacker 2016-10-27 07:15:16 UTC
> (In reply to Ralf Habacker from comment #10)
> Another fix is to place classes into packages not into folder.
This advice is incomplete: While it helped for the minimal testcase, applying to the initial file has still issues.
Comment 13 Ralf Habacker 2016-10-28 10:29:54 UTC
I finally got a solution for this issue, which is divided into two parts: 
1. Because it can happens that diagrams are defined in the xmi file before the related uml object, loading of uml diagrams is delayed until all uml objects are loaded into the umbrello object model. (In principal it would be able to implement this by using forward declaration support, but this looks much more complex and may introduce additional bugs. Any hints in this direction is welcome.)

2. The second issue is that the current implementation of the tree view saves and loads entries to and from a separate xmi file <listview> section. On loading the tree view reparents uml object if the hierachy differs from the uml object tree which makes it very hard to fix broken xmi files by hand because it is required to keep the listview entries in sync with the object model in the file (this explains the possible workaround in comment 7).  Because the tree view entries are always reconstructed from the uml model on xmi file loading (except diagrams which may be fixed also) it looks better to remove this reparenting. 

Thinking about this it may also be possible to remove this redundant storage, but it need to be checked if also diagram widgets not having any uml object are also reconstructed.
Comment 14 Ralf Habacker 2016-11-03 08:58:51 UTC
Git commit 7c761dac4ba3a90e4cfce99d653992f77d5c7147 by Ralf Habacker.
Committed on 03/11/2016 at 08:58.
Pushed by habacker into branch 'Applications/16.08'.

Fix 'Lost class and interface names when open the project'.

UML objects used on diagrams may be located in the xmi file after the
diagram which results into "LOST_..." entries in the tree view. Caused by
internal limitations umbrello 2.18.x was not be able to fix that issues.
It was required to patch the xmi file by hand to remove the incorrect
listview tags.

To fix this issue there are three changes required:

1. Loading of diagrams is now performed after all uml objects has been
   loaded from the xmi file. On parsing diagram tags the related QDomNode
   and UMLFolder instance are saved in a map. After loading has been
   finished the diagrams are imported from this map.

2. Ignore uml objects from xmi file having no parent

3. Do not reparent uml objects caused by list view entries diverged
   from the uml model.
FIXED-IN:2.20.3 (KDE Applications 16.08.03)


Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>

M  +38   -0    umbrello/umldoc.cpp
M  +8    -0    umbrello/umldoc.h
M  +2    -20   umbrello/umllistview.cpp
M  +13   -4    umbrello/umlmodel/folder.cpp
M  +3    -1    umbrello/umlmodel/folder.h

http://commits.kde.org/umbrello/7c761dac4ba3a90e4cfce99d653992f77d5c7147