fix segfault when Update() is called inbetween mouse-up and mouse-down

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54946 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Benjamin Williams
2008-08-03 10:09:43 +00:00
parent 4c0ce682d8
commit d19390718e

View File

@@ -2391,6 +2391,7 @@ void wxAuiManager::GetDockSizeConstraint(double* width_pct, double* height_pct)
void wxAuiManager::Update() void wxAuiManager::Update()
{ {
m_hover_button = NULL; m_hover_button = NULL;
m_action_part = NULL;
wxSizer* sizer; wxSizer* sizer;
int i, pane_count = m_panes.GetCount(); int i, pane_count = m_panes.GetCount();
@@ -4184,17 +4185,21 @@ void wxAuiManager::OnLeftUp(wxMouseEvent& event)
{ {
m_hover_button = NULL; m_hover_button = NULL;
m_frame->ReleaseMouse(); m_frame->ReleaseMouse();
UpdateButtonOnScreen(m_action_part, event);
if (m_action_part)
// make sure we're still over the item that was originally clicked
if (m_action_part == HitTest(event.GetX(), event.GetY()))
{ {
// fire button-click event UpdateButtonOnScreen(m_action_part, event);
wxAuiManagerEvent e(wxEVT_AUI_PANE_BUTTON);
e.SetManager(this); // make sure we're still over the item that was originally clicked
e.SetPane(m_action_part->pane); if (m_action_part == HitTest(event.GetX(), event.GetY()))
e.SetButton(m_action_part->button->button_id); {
ProcessMgrEvent(e); // fire button-click event
wxAuiManagerEvent e(wxEVT_AUI_PANE_BUTTON);
e.SetManager(this);
e.SetPane(m_action_part->pane);
e.SetButton(m_action_part->button->button_id);
ProcessMgrEvent(e);
}
} }
} }
else if (m_action == actionClickCaption) else if (m_action == actionClickCaption)
@@ -4257,20 +4262,23 @@ void wxAuiManager::OnMotion(wxMouseEvent& event)
if (m_action == actionResize) if (m_action == actionResize)
{ {
wxPoint pos = m_action_part->rect.GetPosition(); if (m_action_part)
if (m_action_part->orientation == wxHORIZONTAL) {
pos.y = wxMax(0, event.m_y - m_action_offset.y); wxPoint pos = m_action_part->rect.GetPosition();
else if (m_action_part->orientation == wxHORIZONTAL)
pos.x = wxMax(0, event.m_x - m_action_offset.x); pos.y = wxMax(0, event.m_y - m_action_offset.y);
else
pos.x = wxMax(0, event.m_x - m_action_offset.x);
wxRect rect(m_frame->ClientToScreen(pos), wxRect rect(m_frame->ClientToScreen(pos),
m_action_part->rect.GetSize()); m_action_part->rect.GetSize());
wxScreenDC dc; wxScreenDC dc;
if (!m_action_hintrect.IsEmpty()) if (!m_action_hintrect.IsEmpty())
DrawResizeHint(dc, m_action_hintrect); DrawResizeHint(dc, m_action_hintrect);
DrawResizeHint(dc, rect); DrawResizeHint(dc, rect);
m_action_hintrect = rect; m_action_hintrect = rect;
}
} }
else if (m_action == actionClickCaption) else if (m_action == actionClickCaption)
{ {
@@ -4280,8 +4288,9 @@ void wxAuiManager::OnMotion(wxMouseEvent& event)
// caption has been clicked. we need to check if the mouse // caption has been clicked. we need to check if the mouse
// is now being dragged. if it is, we need to change the // is now being dragged. if it is, we need to change the
// mouse action to 'drag' // mouse action to 'drag'
if (abs(event.m_x - m_action_start.x) > drag_x_threshold || if (m_action_part &&
abs(event.m_y - m_action_start.y) > drag_y_threshold) (abs(event.m_x - m_action_start.x) > drag_x_threshold ||
abs(event.m_y - m_action_start.y) > drag_y_threshold))
{ {
wxAuiPaneInfo* pane_info = m_action_part->pane; wxAuiPaneInfo* pane_info = m_action_part->pane;