wxTaskBarIcon Exit Menu

Chris chrismc911 at hotmail.com
Mon Aug 13 14:41:14 PDT 2007


On 31 Jul., 18:46, va... at wxwidgets.org (Vadim Zeitlin) wrote:
> On Tue, 31 Jul 2007 15:55:47 -0000 Chris <chrismc... at hotmail.com> wrote:
>
> C> thanks for your reply. I tried that but it does not help. I stepped
> C> into the code and the problem is the following (I have wxWidgets 2.8.0
> C> under Windows):
> C>
> C> 1. In taskbarcmn.cpp line 46 the popup menu is created and the
> C> function PopupMenu called in line 49.
> C> 2. PopupMenu show the menu in line 211 of taskbar.cpp.
> C> 3. This brings up my custom menu with the exit button.
> C> 4. The function PopupMenu returns when the user made a selection in
> C> the menu
> C> 5. In my case this fires off the parent->Close() function
> C> 6. Now the parent is getting destroyed and deletes the taskbar obj
>
>  So this is where you'd rather call Destroy()?
>
> C> 7. THEN line 213 of taskbar.cpp is executed but the taskbar obj itself
> C> in which the call is right now has already been deleted.
>
>  The line numbers have changed since then so I don't really see why exactly
> does it crash. What is the line 213 in your version?
>
> C> So I would need some kind of Destroy function for wxTaskBaricon to
> C> prevent deletion of the obj until all messages have been walked
> C> through.
>
>  It should be possible to put it in wxPendingDelete list. If you can make a
> patch implementing Destroy() for it, it would be great.

Hi Vadim and wxWidgets people,

I made a small Destroy function in my TaskBar-class which looks like
this and call it instead of directly using delete:

void TaskBarIcon::Destroy ()
{
	wxPendingDelete.Append (this);
}

It works fine for me, but I don't know if this is the whole trick or
if there may araise any problems with other stuff. If anyone can point
out if this is enough (it does the trick for me ...) so I can work out
more details and finally create a patch.

Regards,
Chris








More information about the wx-users mailing list