Bug 357373 - When opening a saved file, class positions are wrong
Summary: When opening a saved file, class positions are wrong
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: 2.17.2 (KDE Applications 15.08.2)
Platform: Ubuntu Linux
: NOR major
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-31 18:51 UTC by milasudril
Modified: 2016-01-23 22:45 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 2.18.2 (KDE Applications 15.12.2)


Attachments
Saved xmi file (224.65 KB, text/x-xmi)
2016-01-11 10:14 UTC, milasudril
Details
The layout before saving project (452.29 KB, image/png)
2016-01-11 10:16 UTC, milasudril
Details
After opening the project again (170.76 KB, image/png)
2016-01-11 10:18 UTC, milasudril
Details
Resaved broken file (222.32 KB, text/x-xmi)
2016-01-16 19:43 UTC, milasudril
Details

Note You need to log in before you can comment on or make changes to this bug.
Description milasudril 2015-12-31 18:51:59 UTC
The summary should be enough 

Reproducible: Always

Steps to Reproduce:
1. Save a project
2. Close umbrello
3. Open it again

Actual Results:  
Classes position is messed up when reopening the file

Expected Results:  
The saved layout should be preserved
Comment 1 Ralf Habacker 2016-01-01 13:32:22 UTC
Please provide a related test xmi file.
Comment 2 milasudril 2016-01-11 10:14:44 UTC
Created attachment 96583 [details]
Saved xmi file
Comment 3 milasudril 2016-01-11 10:16:23 UTC
Created attachment 96584 [details]
The layout before saving project
Comment 4 milasudril 2016-01-11 10:18:16 UTC
Created attachment 96585 [details]
After opening the project again
Comment 5 Ralf Habacker 2016-01-11 10:36:37 UTC
(In reply to milasudril from comment #4)
> Created attachment 96585 [details]
> After opening the project again

I assume, you are using a self compiled version 2.17.2 (KDE 4) on ubuntu ?  (Official version are older https://apps.ubuntu.com/cat/applications/saucy/umbrello/)

I opened  this xmi-file with self compiled 2.17.2 (KDE 4) and could not reproduce this issue. Can you  please save the xmi file after reloading and append it also to this bug ?
Comment 6 milasudril 2016-01-16 19:43:34 UTC
Created attachment 96688 [details]
Resaved broken file
Comment 7 milasudril 2016-01-16 19:46:57 UTC
(In reply to Ralf Habacker from comment #5)
> (In reply to milasudril from comment #4)
> > Created attachment 96585 [details]
> > After opening the project again
> 
> I assume, you are using a self compiled version 2.17.2 (KDE 4) on ubuntu ? 
> (Official version are older
> https://apps.ubuntu.com/cat/applications/saucy/umbrello/)
> 
> I opened  this xmi-file with self compiled 2.17.2 (KDE 4) and could not
> reproduce this issue. Can you  please save the xmi file after reloading and
> append it also to this bug ?

I am not on Saucy, but Wily and the package is 4:15.08.2-0ubuntu1 from wily/universe not self compiled.
Comment 8 milasudril 2016-01-16 20:42:42 UTC
I tried to compile the git repo, but the bug is also present in Version 2.19.99-367c845. Can there be a broken library instead?
Comment 9 Ralf Habacker 2016-01-22 21:24:46 UTC
(In reply to milasudril from comment #6)
> Created attachment 96688 [details]
> Resaved broken file

(In reply to milasudril from comment #8)
> I tried to compile the git repo, but the bug is also present in Version
> 2.19.99-367c845. Can there be a broken library instead?

After looking into the broken file there are several x coordinates zero, which may happen with incorrect local settings eg ',' as decimal mark. 

I verifed this by changing the locale on my workstation to en_US (defaul de_DE), loaded classes.xmi again and saw the same issue.

umbrello need to save coordinates to and load them from xmi file locale independently using '.' als decimal mark.
Comment 10 Ralf Habacker 2016-01-22 21:50:30 UTC
(In reply to Ralf Habacker from comment #9)

> I verifed this by changing the locale on my workstation to en_US (defaul
> de_DE), loaded classes.xmi again and saw the same issue.

from http://doc.qt.io/qt-5/qstring.html#toFloat
"... The string conversion will always happen in the 'C' locale. For locale dependent conversion use QLocale::toFloat() .."

On a german linux opensuse os I can reproduce the issue  with 
LC_NUMERIC=en_US.UTF-8 umbrello
Comment 11 Ralf Habacker 2016-01-23 21:09:40 UTC
Git commit 90517660d6a14da833ea6cb7c1641bcdfe6c1d2b by Ralf Habacker.
Committed on 23/01/2016 at 21:10.
Pushed by habacker into branch 'Applications/15.12'.

Fix 'When opening a saved file, class positions are wrong'.

The bug, which exists in Qt4 and 5, happens on saving xmi
files using a locale dependent decimal point and is caused
by a different implementation of void
QDomElement::setAttribute(const QString& name, double value)
not using the 'C' locale for converting floating point values
to string as the other number related methods does.

Therefore the bug fix is to use QString::number(), which uses
the 'C' locale.

Add related unit test.
FIXED-IN:2.18.2 (KDE Applications 15.12.2)

M  +2    -2    umbrello/umlscene.cpp
M  +2    -2    umbrello/umlwidgets/associationline.cpp
M  +4    -4    umbrello/umlwidgets/umlwidget.cpp
M  +118  -1    unittests/TEST_basictypes.cpp
M  +4    -0    unittests/TEST_basictypes.h

http://commits.kde.org/umbrello/90517660d6a14da833ea6cb7c1641bcdfe6c1d2b
Comment 12 Ralf Habacker 2016-01-23 21:32:14 UTC
For the record: The issue happens when opening an xmi file on a linux os with english locale, which has been generated with umbrello < 2.18.2 on a linux os with non english linux.
Comment 13 Ralf Habacker 2016-01-23 22:45:55 UTC
Git commit 65296dc299319e0ad4675353100e582054987f81 by Ralf Habacker.
Committed on 23/01/2016 at 22:09.
Pushed by habacker into branch 'Applications/15.12'.

fixup of 90517660d6a14da833ea6cb7c1641bcdfe6c1d2b.

M  +4    -4    umbrello/umlwidgets/associationline.cpp

http://commits.kde.org/umbrello/65296dc299319e0ad4675353100e582054987f81
Comment 14 Ralf Habacker 2016-01-23 22:45:55 UTC
Git commit 59ab483bac9104ec12dee4a98a0a9dcca4dd7636 by Ralf Habacker.
Committed on 23/01/2016 at 22:33.
Pushed by habacker into branch 'Applications/15.12'.

Fix loading of XMI files on linux os generated with non english locale.

XMI files generated on linux os with non english locale contains ','
as decimal point, which is not readable on os with english locale.

M  +21   -0    umbrello/basictypes.cpp
M  +2    -0    umbrello/basictypes.h
M  +6    -6    umbrello/umlwidgets/associationline.cpp
M  +3    -3    umbrello/umlwidgets/umlwidget.cpp

http://commits.kde.org/umbrello/59ab483bac9104ec12dee4a98a0a9dcca4dd7636
Comment 15 Ralf Habacker 2016-01-23 22:45:56 UTC
Git commit 15117e4ca041b5d3241cd75edf900b8dd5d5163d by Ralf Habacker.
Committed on 23/01/2016 at 22:45.
Pushed by habacker into branch 'Applications/15.12'.

Keep loading type of XMI file attributes "xclicked", "yclicked", "minY" and "maxY" in sync with saving.

M  +2    -2    umbrello/umlwidgets/floatingdashlinewidget.cpp
M  +2    -2    umbrello/umlwidgets/messagewidget.cpp

http://commits.kde.org/umbrello/15117e4ca041b5d3241cd75edf900b8dd5d5163d