EVT_ACTIVEX(eventName, id, fn) calls RegisterActiveXEvent() which adds events to sg_NamedEventMap and sg_dispIdEventMap (depending on which overload is called) sg_NamedEventMap and sg_dispIdEventMap are statically defined in the same file.
The problem is that the static initializers for the event tables (where you call EVT_ACTIVEX from) can be called before sg_NamedEventMap and sg_dispIdEventMap are themselves statically initialized. In the example code this seems to work OK... its just luck that they are initialized in the correct order. However if you make you own class to call these, there's no guarantee that they'll be initialized in the right order and it'll crash on initialization.
My solution is to turn sg_NamedEventMap and sg_dispIdEventMap into pointers (which should initially be NULL).
Then in the RegisterActiveXEvent functions, test to see if they are NULL and if so, initialize them before using them.
static ActiveXNamedEventMap *sg_NamedEventMap=NULL;
const wxEventType& RegisterActiveXEvent(const wxChar *eventName)
{
if(sg_NamedEventMap==NULL) sg_NamedEventMap=new ActiveXNamedEventMap();
[...]
static ActiveXDISPIDEventMap *sg_dispIdEventMap;
const wxEventType& RegisterActiveXEvent(DISPID event)
{
if(sg_dispIdEventMap==NULL) sg_dispIdEventMap=new ActiveXDISPIDEventMap();
If you do this, you have to convert everyplace that uses them to -> notation instead of . notation. The compiler will show you where.
You also need to wrap the sections of ~ActibveXEventMapFlusher() and DispatchEvent() where these are used in if statements to skip the sections if these are NULL.
Logged In: YES
user_id=229231
Originator: YES
Attached is the whole patched file. I believe it has some other minor fixes too (as suggested in the bug list).
File Added: wxactivex.cpp
Logged In: YES
user_id=229231
Originator: YES
File Added: wxactivex.cpp
Logged In: YES
user_id=229231
Originator: YES
another revision to the patched file
File Added: wxactivex.cpp
wxactivex.cpp patched