Thanks Thomas,
It works. Good to know this, since it is a bit surprising that you loose ownership.
It is strange that I did not get a crash when I close cb, since in my destructor I checked my 'sub'menu pointer, and if it is still != NULL I delete it. So taking into account your words, I would have been a second delete.
This whole stuff might be dangerous, since I allocate (in my dll), it get's freed in another dll/exe I guess, the application in charge of the menu ?? What if both are build differently, release build <---> debug build. I know for example in M$ Dev Studio, one had to make sure alloc/free had to originate from the same flavour(debug,release, single/multi-thread).
As I see it here, this danger is lurking at us.
I think it would have been better that the Append/Insert/Prepend of a submenu would have been done by a pointer pointer, in that way you could check on the 'pointer' to be NULL or not, so if it got allocated by someone else they could have set the value of the pointer to NULL, and one could check through *pointerpointer. Pff, always suspicous for memory leaks. :?
Or event better, if you want to append a (sub)menu, wx could create it on the inside, then ownership did not have to be transfered, and alloc/free could happen in the same environment. And you could get a handle back for adding the entries.
But these are wx issued not cb's.
kind regards,
Lieven