On 15/03/2011 22:00, Mattia Barbon wrote:
But, now of course I have Perl data and no automatic destruction.
From looking at the code, using O_WXOBJECT it should work correctly,
what problems are you seeing/thinking of?
I'm currently barely competent at coding C/C++ but have decided its time
to change that. Moving between perldocs and helpers.cpp / helpers.h
making sure I properly understand what is happening is currently a slow
process - but I'm getting there. I just haven't properly followed
through how object destruction is synchronised for the different object
types yet. So I was really saying 'now its an O_WXOBJECT I'm not sure
how it gets destroyed'. But I'll get there.
You probably have noticed that wxPli_object_2_sv calls
wxPli_evthandler_2_sv if appropriate, so O_WXOBJECT can be applied to
any wxEvtHandler subclass, it just does some extra (unnecessary) work
before calling GetClientObject().
Yes, I just wasn't sure about object destruction.
I see three possible solutions:
1) add a different virtual callback handler for wxEvtHandler-derived
classes (that gets the perl object from GetClientObject)
2) change wxPli_create_evthandler to transparently use the existing
instance if present, and call wxPli_make_object otherwise
3) add a separate wxPli_set_evthandler (or something) that needs to
be used instead of wxPli_create_evthandler for
wxEvtHandler-derived classes with virtual methods
In all three cases, wxPlVListBox uses O_WXEVTHANDLER.
I prefer 2 (simpler, easier for XS++/code generation); the only
advantage of 3 is slightly faster runtime (but I doubt it's noticeable);
I listed 1 for completeness, because it wat the first thing I thought
of, but it can't think of any advantages over 2 or 3.
2 seems the best solution to me also. 1 was the solution that occurred
to me so is almost certainly wrong or too simplistic :-). 3 would
require changes to quite a few classes or making
wxPli_create_evthandler context smart in some way.
2 requires one change which would seem to be totally transparent to any
other code. (Famous last words of course).
I shall have a go at changing and testing.
Thanks as always for your explanations and help.
Regards
Mark