[Uml-devel] umbrello-soc assert

Gopala Krishna krishna.ggk at gmail.com
Tue Aug 18 10:14:32 UTC 2009


Hi Ralf,

On Tue, Aug 18, 2009 at 3:28 PM, Ralf Habacker<ralf.habacker at freenet.de> wrote:
> Hi,
>
> when loading the following file
> http://websvn.kde.org/*checkout*/trunk/kdesupport/emerge/doc/refactoring.xmi?revision=999553&content-type=text%2Fplain
> on windows umbrello-soc crashes in
>
>  >    umbrello-soc.exe!WidgetBase::loadFromXMI(QDomElement &
> qElement={...})  Zeile 502 + 0x23 Bytes    C++
>     umbrello-soc.exe!AssociationWidget::loadFromXMI(QDomElement &
> qElement={...}, const QList<UMLWidget *> & widgets={...}, const
> QList<MessageWidget *> * pMessages=0x0000019c)  Zeile 987    C++
>     umbrello-soc.exe!AssociationWidget::loadFromXMI(QDomElement &
> element={...})  Zeile 1251    C++
> [snip]
> It runs on the following assert. Any idea how to fix this issue ?
>
> bool WidgetBase::loadFromXMI(QDomElement &qElement)
> {
>    Q_ASSERT(umlScene());
>    // NOTE:
>    // The "none" is used by kde3 version of umbrello. The current
>    // technique to determine whether a property is being used from
>    // the diagram or not is just to compare the same, rather than
>    // having flags for them.
>    //
>    // This way, there is no burden to update the flags and the code
>    // is more robust.

I added this assert in one of the commits today, the reason being a
Widget should be on a UMLScene while loading from XMI.
This is because, all the widgets from now on save their (x,y) position
in terms of scene coordinates to provide compatibility with older
versions of umbrello. To map a widget's coordinates to its scene
coordinates requires it be on the UMLScene.

So the fix is usually to replace code like

if(widget->loadFromXMI(element)) {
scene->addWidget(widget)
} else {
 delete widget;
}

with

scene->addItem(widget); // only add as an item, not registered in
widgetlist of UMLScene yet
if (widget->loadFromXMI(element)) {
 scene->addWidget(widget); // now register it with UMLScene as well.
} else {
 scene->removeItem(widget);
 delete widget;
}



-- 
Cheers,
Gopala Krishna A




More information about the umbrello-devel mailing list