From 6707bb940681309773b0015f553979f5075a2a1d Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Sat, 28 Aug 2004 19:10:31 +0000 Subject: [PATCH] Patch #1003174: Fixes crash when toolbar has a disabled control from Ian Brown. If you put a control (e.g. a wxChoice) on a toolbar and then later disable that control, you will get a crash. This is because the toolbar code always calls disable on the button widget for a toolbartool. When the tool is a control, there is no button, and you should call disable on the control instead. This small patch implements this logic. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28940 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/motif/toolbar.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/motif/toolbar.cpp b/src/motif/toolbar.cpp index 00da4412b6..54a6419baa 100644 --- a/src/motif/toolbar.cpp +++ b/src/motif/toolbar.cpp @@ -592,8 +592,12 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) void wxToolBar::DoEnableTool(wxToolBarToolBase *toolBase, bool enable) { wxToolBarTool *tool = (wxToolBarTool *)toolBase; - - XtSetSensitive(tool->GetButtonWidget(), (Boolean) enable); + if (tool->GetButtonWidget()){ + XtSetSensitive(tool->GetButtonWidget(), (Boolean) enable); + } else if (wxTOOL_STYLE_CONTROL == tool->GetStyle()){ + // Controls (such as wxChoice) do not have button widgets + tool->GetControl()->Enable(enable); + } } void wxToolBar::DoToggleTool(wxToolBarToolBase *toolBase, bool toggle) -- 2.45.2