[Uml-devel] [Bug 63248] Crash when cutting a class

Jean-Louis Houberdon jl.houberdon at laposte.net
Thu Aug 28 08:12:06 UTC 2003


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
     
http://bugs.kde.org/show_bug.cgi?id=63248     




------- Additional Comments From jl.houberdon at laposte.net  2003-08-28 17:10 -------
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




More information about the umbrello-devel mailing list