From 6f26925422c2de7938509657eb981d6f752a6249 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 2 Nov 2010 11:57:03 +0000 Subject: [PATCH] Avoid crash when releasing the mouse in wxRibbonToolBar. The active tool pointer can be changed/set to NULL by the event handler in wxRibbonToolBar::OnMouseUp() so test for it before using it after processing the event. Closes #12640. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/ribbon/toolbar.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ribbon/toolbar.cpp b/src/ribbon/toolbar.cpp index 475db49bf0..cd4817e0a2 100644 --- a/src/ribbon/toolbar.cpp +++ b/src/ribbon/toolbar.cpp @@ -661,9 +661,15 @@ void wxRibbonToolBar::OnMouseUp(wxMouseEvent& WXUNUSED(evt)) notification.SetBar(this); ProcessEvent(notification); } - m_active_tool->state &= ~wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK; - m_active_tool = NULL; - Refresh(false); + + // Notice that m_active_tool could have been reset by the event handler + // above so we need to test it again. + if (m_active_tool) + { + m_active_tool->state &= ~wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK; + m_active_tool = NULL; + Refresh(false); + } } } -- 2.45.2