]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/bookctrl.cpp
remove assert from PurgeOtherRepresentations,we'll have to trust that callers know...
[wxWidgets.git] / src / common / bookctrl.cpp
index d194cc20a9ccee7da88a2fd2b711b5fa8d4f9113..fef420180a359574454f991430996f4270b6a54e 100644 (file)
@@ -423,24 +423,25 @@ wxSize wxBookCtrlBase::GetControllerSize() const
     return size;
 }
 
-int wxBookCtrlBase::DoSetSelection(size_t n, int flags, wxBookCtrlBaseEvent &event)
+int wxBookCtrlBase::DoSetSelection(size_t n, int flags)
 {
     wxCHECK_MSG( n < GetPageCount(), wxNOT_FOUND,
                  wxT("invalid page index in wxBookCtrlBase::DoSetSelection()") );
 
     const int oldSel = GetSelection();
 
-    if ( oldSel != wxNOT_FOUND && n != (size_t)oldSel )
+    if ( n != (size_t)oldSel )
     {
+        wxBookCtrlBaseEvent *event = CreatePageChangingEvent();
         bool allowed = false;
 
         if ( flags & SetSelection_SendEvent )
         {
-            event.SetSelection(n);
-            event.SetOldSelection(oldSel);
-            event.SetEventObject(this);
+            event->SetSelection(n);
+            event->SetOldSelection(oldSel);
+            event->SetEventObject(this);
 
-            allowed = !GetEventHandler()->ProcessEvent(event) || event.IsAllowed();
+            allowed = !GetEventHandler()->ProcessEvent(*event) || event->IsAllowed();
         }
 
         if ( !(flags & SetSelection_SendEvent) || allowed)
@@ -458,10 +459,12 @@ int wxBookCtrlBase::DoSetSelection(size_t n, int flags, wxBookCtrlBaseEvent &eve
             if ( flags & SetSelection_SendEvent )
             {
                 // program allows the page change
-                MakeChangedEvent(event);
-                (void)GetEventHandler()->ProcessEvent(event);
+                MakeChangedEvent(*event);
+                (void)GetEventHandler()->ProcessEvent(*event);
             }
         }
+
+        delete event;
     }
 
     return oldSel;