Salome HOME
refs #550: fix crash when myObject is NULL
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DataModelSync.cxx
index 58808f117e2674f6d9431c5ab31bf9d5bea8c2b7..b73f3a401405c9bff23c0feb8c1af39552113735 100644 (file)
@@ -1,6 +1,24 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include <HYDROGUI_DataModelSync.h>
 #include <HYDROGUI_DataObject.h>
+#include <typeinfo>
 
 HYDROGUI_DataModelSync::HYDROGUI_DataModelSync( SUIT_DataObject* theRoot )
   : myRoot( theRoot )
@@ -16,12 +34,8 @@ void HYDROGUI_DataModelSync::deleteItemWithChildren( const suitPtr& theSuitPtr )
   if( !theSuitPtr )
     return;
 
-  DataObjectList aChildren;
-  theSuitPtr->children( aChildren );
-  foreach( SUIT_DataObject* anObj, aChildren )
-    deleteItemWithChildren( anObj );
-
-  delete theSuitPtr;
+  theSuitPtr->setAutoDeleteChildren( true );
+  theSuitPtr->deleteLater();
 }
 
 suitPtr HYDROGUI_DataModelSync::nullSrc() const