Changing toolbar tool bitmaps (wxMac problem)

Robin Dunn robin at alldunn.com
Tue Jan 23 15:53:28 PST 2007


Hi (Stefan),

I'm trying to figure out how to change the bitmap for a tool on a =

toolbar.  My first guess does work on Windows, but not the other platforms:

	tool =3D toolbar->FindById(theID);
	tool->SetNormalBitmap(newBmp);
	toolbar->Realize();


After digging in the code it looks like removing the tool and then =

inserting it back is probably necessary, and this does work on wxMSW and =

wxGTK, and also on wxMac after a crashing bug is fixed (attached):

	pos =3D toolbar->GetToolPos(theID);
	tool =3D toolbar->RemoveTool(theID);
	tool->SetNormalBitmap(newBmp);
	toolbar->InsertTool(pos, tool);
	toolbar->Realize();

There is still a problem remaining on Mac however.  When the app is =

shutdown after a toolbar has been modified as above, then there is an =

assert and core dump about a control handle being invalid:

[Debug] 14:46:36: ../src/mac/carbon/utils.cpp(866): assert =

"IsValidControlHandle(m_controlRef)" failed in Dispose(): Invalid =

Control Handle (maybe already released) in Dispose
Trace/BPT trap (core dumped)

Digging with gdb shows that the handle it is complaining about belongs =

to the textctrl part of a wxComboBox that is one the toolbar after the =

tool whose bitmap is being changed.  Any ideas on how to fix that?

Is there a better way to change a tool's bitmap?


-- =

Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mac-toolbar.patch
Type: text/x-patch
Size: 1754 bytes
Desc: not available
Url : http://lists.wxwidgets.org/pipermail/wx-dev/attachments/20070123/3de0=
e67e/mac-toolbar.bin


More information about the wx-dev mailing list