[Uml-devel] kdesdk/umbrello/umbrello

Brian Thomas thomas at mail630.gsfc.nasa.gov
Tue Sep 30 12:24:09 UTC 2003


CVS commit by thomas: 

bug fix: codeclassfield removal crashed because inadvertant setting of autoDelete to true on m_classfieldVector QPtrList. This is wrong, as removeCodeClassField needs to do further manipulations of the child code classifield *after* the reference to the child is removed from the m_classfieldVector list.


  M +15 -11    classifiercodedocument.cpp   1.11


--- kdesdk/umbrello/umbrello/classifiercodedocument.cpp  #1.10:1.11
@@ -171,12 +171,5 @@ bool ClassifierCodeDocument::removeCodeC
                         // remove from our classfield map
                         m_classFieldMap->remove(umlobj);
-
-                        // Now remove all of the methods and declaration block it 'owns'
-                        removeTextBlock(remove_object->getDeclarationCodeBlock());
-
-                        QPtrList<CodeAccessorMethod> * methods = remove_object->getMethodList();
-                        for (CodeAccessorMethod * m = methods->first(); m ; m = methods->next())
-                                removeTextBlock(m);
-
+                        delete remove_object;
                         return true;
                 } 
@@ -260,6 +253,17 @@ void ClassifierCodeDocument::addOperatio
  */
 void ClassifierCodeDocument::removeOperation (UMLObject * op ) {
-// FIX
-kdError()<<"REMOVE OPERATION CALLED for op:"<<op<<endl;
+
+        QString tag = CodeOperation::findTag((UMLOperation*)op);
+        TextBlock *tb = findTextBlockByTag(tag, true);
+        if(tb)
+        {
+                if(removeTextBlock(tb)) // wont add if already present
+                        delete tb; // delete unused operations
+                else
+                        kdError()<<"Cant remove CodeOperation from ClassCodeDocument!"<<endl;
+                        
+        }
+        else
+                kdError()<<"Cant Find codeOperation for deleted operation!"<<endl;
 }
 
@@ -304,5 +308,5 @@ void ClassifierCodeDocument::init (UMLCl
         m_parentclassifier = c;
         m_isInterface = dynamic_cast<UMLInterface*>(c) ? true : false; 
-        m_classfieldVector.setAutoDelete(true);
+        m_classfieldVector.setAutoDelete(false);
         m_classFieldMap = new QMap<UMLObject *, CodeClassField*>;
 






More information about the umbrello-devel mailing list