[Uml-devel] [Bug 59774] crash when cutting last diagram left
Jean-Louis Houberdon
jl.houberdon at laposte.net
Sun Aug 31 15:55:02 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=59774
------- Additional Comments From jl.houberdon at laposte.net 2003-09-01 00:54 -------
This patch should solve the second bug (deleting a diagram with associations in it and which has been saved/loaded) :
--- umlview.cpp 2003-08-31 22:46:15.000000000 +0200
+++ umlview.new.cpp 2003-08-31 22:47:27.000000000 +0200
@@ -2197,16 +2197,31 @@
void UMLView::removeAllWidgets() {
- //FIXME bug 59774
- //this queryList returns a too high count and list items which cause the program to crash
- //when you touch them on diagrams that contain associations /and/ have been saved and loaded
- QObjectList * l = queryList( "UMLWidget");
- QObjectListIt it( *l );
+ QObjectList * l = queryList("UMLWidget");
+ QObjectListIt it(*l);
UMLWidget * temp = 0;
- while ( (temp=(UMLWidget*)it.current()) != 0 ) {
+ while ((temp=(UMLWidget*)it.current()) != 0) {
++it;
- if( !( temp -> getBaseType() == wt_Text && ((FloatingText *)temp)-> getRole() != tr_Floating ) ) {
- removeWidget( temp );
+ if( !(temp->getBaseType() == wt_Text && ((FloatingText *)temp)->getRole() != tr_Floating) ) {
+ removeWidget(temp);
+
+ /* 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 ((temp = (UMLWidget*)OldListIt.current()) != 0)
+ {
+ ++OldListIt;
+ if (!currentList->contains(temp))
+ {
+ l->remove(temp);
+ }
+ }
+ it.toFirst();
+ delete currentList;
}
}
delete l;
In fact, it is the same problem as in the [63248] bug (crash when cutting a class).
The fact that it must be saved/loaded to crash (before applying this patch :)) is not really true. If you make a diagram with an association and you rename it (creating the widgets which make finally crash), when you delete the diagram it crashes.
More information about the umbrello-devel
mailing list