Index: sansview/perspectives/fitting/fitpage.py
===================================================================
--- sansview/perspectives/fitting/fitpage.py	(revision 31f9c1725c7be81e4a81ad50f255d45e963b947c)
+++ sansview/perspectives/fitting/fitpage.py	(revision f22e62691664f677f67545d8230e76e836dd2811)
@@ -43,4 +43,5 @@
         self._fill_datainfo_sizer()
         self.is_2D = None
+        self.fit_started = False
         # get smear info from data
         self._get_smear_info()
@@ -982,4 +983,5 @@
         self.bind_fit_button()
            
+   
     def bind_fit_button(self):
         """
@@ -988,8 +990,10 @@
         self.btFit.Unbind(event=wx.EVT_BUTTON, id= self.btFit.GetId())
         if self.btFit.GetLabel().lower() == "stop":
+            self.fit_started = True
             self.btFit.SetForegroundColour('red')
             self.btFit.Bind(event=wx.EVT_BUTTON, handler=self._StopFit,
                              id=self.btFit.GetId())
         elif self.btFit.GetLabel().lower() == "fit":
+            self.fit_started = False
             self.btFit.SetDefault()
             self.btFit.SetForegroundColour('black')
@@ -1002,6 +1006,9 @@
         self._manager._reset_schedule_problem(value=0)
           
-
-    def _StopFit(self, event):
+    def is_fitting(self):
+        if self.fit_started:
+            self._StopFit(event=None)
+            
+    def _StopFit(self, event=None):
         """
         Stop fit 
Index: sansview/perspectives/fitting/fitpanel.py
===================================================================
--- sansview/perspectives/fitting/fitpanel.py	(revision 4bee68de836de3854498b95dc0420e6458ba880c)
+++ sansview/perspectives/fitting/fitpanel.py	(revision f22e62691664f677f67545d8230e76e836dd2811)
@@ -3,4 +3,5 @@
 import string 
 import wx
+import sys
 #from wx.lib.flatnotebook import FlatNotebook as nb
 from wx.aui import AuiNotebook as nb
@@ -46,7 +47,7 @@
         self.model_list_box = self.menu_mng.get_model_list()
         #pageClosedEvent = nb.EVT_FLATNOTEBOOK_PAGE_CLOSING 
-        pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE
-        
-        self.Bind(pageClosedEvent, self.on_close_page)
+        self.pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE
+        
+        self.Bind(self.pageClosedEvent, self.on_close_page)
          ## save the title of the last page tab added
         self.fit_page_name = {}
@@ -61,8 +62,11 @@
         self.Bind(basepage.EVT_NEXT_STATE, self._onRedo)
         self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.on_page_changing)
-
-        #add default pages
-        self.add_default_pages()
-
+        self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSED, self.on_closed)
+
+    def on_closed(self, event):
+        """
+        """
+        print "page closed", self.GetPageCount()
+        
     def save_project(self, doc=None):
         """
@@ -116,4 +120,12 @@
     def on_page_changing(self, event):
         """
+        calls the function when the current event handler has exited. avoiding
+        to call panel on focus on a panel that is currently deleted
+        """
+        wx.CallAfter(self.helper_on_page_change)
+        
+        
+    def helper_on_page_change(self):
+        """
         """
         pos = self.GetSelection()
@@ -121,5 +133,6 @@
             selected_page = self.GetPage(pos)
             wx.PostEvent(self.parent, PanelOnFocusEvent(panel=selected_page))
-            
+        
+       
     def on_set_focus(self, event):
         """
@@ -157,14 +170,5 @@
             return selected_page.get_state()
     
-    def add_default_pages(self):
-        """
-        Add default pages such as a hint page and an empty fit page
-        """
-        pass
-        #add default page
-        #from hint_fitpage import HintFitPage
-        #self.hint_page = HintFitPage(self) 
-        #self.AddPage(self.hint_page,"Hint")
-        #self.hint_page.set_manager(self._manager)
+  
   
     def close_all(self):
@@ -228,9 +232,10 @@
         """
         nbr_page = self.GetPageCount()
+        selected_page = self.GetPage(self.GetSelection())
         if nbr_page == 1:
-           
-            event.Veto()
-            return 
-        selected_page = self.GetPage(self.GetSelection())
+            if selected_page.get_data() == None:
+                if event is not None:
+                    event.Veto()
+                return 
         self._close_helper(selected_page=selected_page)
         
@@ -250,5 +255,5 @@
                     #with no selected data
                     return
-                if data.name == deleted_data.name:
+                if data.id == deleted_data.id:
                     self._close_helper(selected_page)
                     self.DeletePage(index)
@@ -294,4 +299,5 @@
         self.AddPage(self.sim_page,"Simultaneous Fit", True)
         self.sim_page.set_manager(self._manager)
+        self.enable_close_button()
         return self.sim_page
         
@@ -310,12 +316,45 @@
         self.opened_pages[panel.uid] = panel
         self.set_engine_helper(panel=panel)
+        self.enable_close_button()
         return panel 
     
+    def enable_close_button(self):
+        """
+        display the close button on tab for more than 1 tabs else remove the 
+        close button
+        """
+        return
+        if self.GetPageCount() <= 1:
+            style = self.GetWindowStyleFlag() 
+            if style & wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB == wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB:
+                style = style & ~wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
+                self.SetWindowStyle(style)
+        else:
+            style = self.GetWindowStyleFlag()
+            if style & wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB != wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB:
+                style |= wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
+                self.SetWindowStyle(style)
+            
     def delete_data(self, data):
         """
         Delete the given data
         """
-        if data is None:
-            return None
+        if data.__class__.__name__ != "list":
+            raise ValueError, "Fitpanel delete_data expect list of id"
+        else:
+            n = self.GetPageCount()
+            for page in self.opened_pages.values():
+                pos = self.GetPageIndex(page)
+                temp_data = page.get_data()
+                #stop the fitting before deleting the page
+                page.is_fitting()
+                if temp_data is not None and temp_data.id in data:
+                    self.SetSelection(pos)
+                    self.on_close_page(event=None)
+                    temp = self.GetSelection()
+                    self.DeletePage(temp)
+            if self.GetPageCount()== 0:
+                self.add_empty_page()
+        
     def set_data(self, data):
         """ 
@@ -435,8 +474,7 @@
         for uid, list in self.opened_pages.iteritems():
             #Don't return any panel is the exact same page is created
-            
             if selected_page.uid == uid:
                 del self.opened_pages[selected_page.uid]
                 break 
-     
+      
   
Index: sansview/perspectives/fitting/fitting.py
===================================================================
--- sansview/perspectives/fitting/fitting.py	(revision b92cbf615778e89f306dd3e59f84a68d733bab01)
+++ sansview/perspectives/fitting/fitting.py	(revision f22e62691664f677f67545d8230e76e836dd2811)
@@ -227,5 +227,5 @@
         loader = Loader()
         loader.associate_file_reader(".fitv", self.state_reader)
-        loader.associate_file_reader(".svs", self.state_reader)
+        #loader.associate_file_reader(".svs", self.state_reader)
         from sans.perspectives.calculator.sld_panel import SldPanel
         #Send the fitting panel to guiframe
@@ -266,4 +266,6 @@
             if dlg.ShowModal() == wx.ID_OK:
                 selected_data_list = dlg.get_data()
+            dlg.Destroy()
+            
         else:
             selected_data_list = data_list
