Hi,
Mattia Barbon wrote:
The point of the CLONE/DESTROY pair in wxPerl classes is avoiding
crashes/double free errors. None of the classes that have a
CLONE/DESTROY pair work inside a thread.
The DESTROY method is needed, otherwise the objects will leak. Once
you have a DESTROY, you need a CLONE to work with threads, without it:
- an object is allocated
- a thread starts and copies the Perl-level object
- the thread ends, runs DESTROY methods and frees the C++ object
- the main program ends, tries to free the already-freed C++ object
and crashes
the CLONE used by wxPerl avoids the first free (the one at thread end)
by NULL-ing all wxPerl objects inside a thread.
well, maybe getting it totally back to front is easier to correct than
only getting it slightly wrong. :-)
Resolved now.
Threads were not the problem - creation / destruction order of the
objects was - so the threads test was crashing but producing no
meaningful output.
So CLONE & DESTROY methods restored, threads test now works.
Also added a simple overlay test to check no crash on correct usage.
Mark