Summary: | Crash when cutting a class | ||
---|---|---|---|
Product: | [Applications] umbrello | Reporter: | Sebastian Stein <seb.kde> |
Component: | general | Assignee: | Umbrello Development Group <umbrello-devel> |
Status: | RESOLVED FIXED | ||
Severity: | crash | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | Cut one of both classes and it will crash |
Description
Sebastian Stein
2003-08-25 17:34:48 UTC
Created attachment 2308 [details]
Cut one of both classes and it will crash
I found a way to correct the bug : --- umlview.old 2003-08-28 16:47:42.000000000 +0200 +++ umlview.cpp 2003-08-28 16:50:24.000000000 +0200 @@ -586,16 +586,32 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// void UMLView::slotObjectRemoved(UMLObject * o) { m_bPaste = false; - int id = o -> getID(); - QObjectList * l = queryList( "UMLWidget"); - QObjectListIt it( *l ); + int id = o->getID(); + QObjectList * l = queryList("UMLWidget"); + QObjectListIt it(*l); UMLWidget *obj; - while ((obj=(UMLWidget*)it.current()) != 0 ) { + while ((obj=(UMLWidget*)it.current()) != 0) { ++it; - if(obj -> getID() == id) + if(obj->getID() == id) { removeWidget(obj); + + /* Update list */ + QObjectList * currentList = queryList("UMLWidget"); + QObjectListIt OldListIt(*l); + + while ((obj = (UMLWidget*)OldListIt.current()) != 0) + { + ++OldListIt; + if (!currentList->contains(obj)) + { + l->remove(obj); + } + } + it.toFirst(); + delete currentList; + } } delete l; Justification of the correction : When you remove the widget (i.e. here the class widget), you remove association widgets too in the same time. So, when you come back to the loop and ask for "obj->getID()" on the next widget, it is possible you have deleted it meanwhile. So, it's necessary to update the object list to be sure you don't have a widget which doesn't exist. Jean-Louis Houberdon Subject: Re: Crash when cutting a class fixed by Jean-Louis Houberdon: When you remove the widget (i.e. here the class widget), you remove association widgets too in the same time. So, when you come back to the loop and ask for "obj->getID()" on the next widget, it is possible you have deleted it meanwhile. So, it's necessary to update the object list to be sure you don't have a widget which doesn't exist. |