[Uml-devel] kdesdk/umbrello/umbrello

Sebastian Stein seb.kde at hpfsc.de
Sun Aug 31 06:36:16 UTC 2003


CVS commit by sstein: 

fix bug 63248: patch provided 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.


  M +22 -4     umlview.cpp   1.75


--- kdesdk/umbrello/umbrello/umlview.cpp  #1.74:1.75
@@ -587,14 +587,32 @@ void UMLView::slotObjectCreated(UMLObjec
 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)
                 {
                         removeWidget(obj);
+
+                        /* Update list; removing a widget will also delete the associations
+                         * connected to it; so we have to update the list, because other
+                         * widgets might be already deleted
+                         */
+                        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;
                 }
         }






More information about the umbrello-devel mailing list