]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed crash in multi notebook
authorBenjamin Williams <bwilliams@kirix.com>
Fri, 27 Oct 2006 15:52:21 +0000 (15:52 +0000)
committerBenjamin Williams <bwilliams@kirix.com>
Fri, 27 Oct 2006 15:52:21 +0000 (15:52 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42536 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/aui/auibook.cpp

index 0b67e2e8f9fe8f07066c4fdd0e992e6657dc86d2..12511fae347db79a916b4e73a871061875ed7851 100644 (file)
@@ -1028,9 +1028,9 @@ bool wxAuiMultiNotebook::InsertPage(size_t page_idx,
 // DeletePage() removes a tab from the multi-notebook,
 // and destroys the window as well
 bool wxAuiMultiNotebook::DeletePage(size_t page_idx)
 // DeletePage() removes a tab from the multi-notebook,
 // and destroys the window as well
 bool wxAuiMultiNotebook::DeletePage(size_t page_idx)
-{
+{    
     wxWindow* wnd = m_tabs.GetWindowFromIdx(page_idx);
     wxWindow* wnd = m_tabs.GetWindowFromIdx(page_idx);
-
+    wxWindow* new_active = NULL;
 
     // find out which onscreen tab ctrl owns this tab
     wxAuiTabCtrl* ctrl;
 
     // find out which onscreen tab ctrl owns this tab
     wxAuiTabCtrl* ctrl;
@@ -1045,33 +1045,24 @@ bool wxAuiMultiNotebook::DeletePage(size_t page_idx)
 
     if (new_idx >= 0 && new_idx < (int)ctrl->GetPageCount())
     {
 
     if (new_idx >= 0 && new_idx < (int)ctrl->GetPageCount())
     {
-        wxWindow* new_wnd = ctrl->GetWindowFromIdx(new_idx);
-        int main_idx = m_tabs.GetIdxFromWindow(new_wnd);
-        wxASSERT(main_idx != -1);
-        SetSelection(main_idx);
+        new_active = ctrl->GetWindowFromIdx(new_idx);
     }
      else
     {
         // set the active page to the first page that
         // isn't the one being deleted
     }
      else
     {
         // set the active page to the first page that
         // isn't the one being deleted
-        bool found = false;
         size_t i, page_count = m_tabs.GetPageCount();
         for (i = 0; i < page_count; ++i)
         {
             wxWindow* w = m_tabs.GetWindowFromIdx(i);
             if (wnd != w)
             {
         size_t i, page_count = m_tabs.GetPageCount();
         for (i = 0; i < page_count; ++i)
         {
             wxWindow* w = m_tabs.GetWindowFromIdx(i);
             if (wnd != w)
             {
-                found = true;
-                SetSelection(i);
+                new_active = m_tabs.GetWindowFromIdx(i);
                 break;
             }
         }
                 break;
             }
         }
-
-        if (!found)
-            m_curpage = -1;
     }
 
     }
 
-
     // remove the tab from main catalog
     if (!m_tabs.RemovePage(wnd))
         return false;
     // remove the tab from main catalog
     if (!m_tabs.RemovePage(wnd))
         return false;
@@ -1094,6 +1085,13 @@ bool wxAuiMultiNotebook::DeletePage(size_t page_idx)
 
     RemoveEmptyTabFrames();
 
 
     RemoveEmptyTabFrames();
 
+    // set new active pane
+    if (new_active)
+    {
+        m_curpage = -1;
+        SetSelection(m_tabs.GetIdxFromWindow(new_active));
+    }
+    
     return true;
 }
 
     return true;
 }