Hi,
Tests suggested passed on Win32 and Linux - but failed on Mac.
Looking into the underlying implementations, on MSWin and Linux, the
wxOverlay object holds on to a reference to a wxBitmap - which worked OK.
On wxMac however, the implementation holds onto a reference to the
client window and a mac graphics object representing the screen ( I think ).
I've removed the CLONE and DESTROY methods for both Wx::Overlay and
Wx::DCOverlay leaving Perl to do the default thing.
My understanding is that this should be OK - the only effect being that
Wx::Overlay and Wx::DCOverlay become like most other GUI objects - only
accessible in the main thread. They would not have been usable in
working code outside the main thread anyway.
The code now passes tests - but that doesn't say much as there are now
no CLONE and DESTROY methods.
The patch I've 'successfully' tested on MSWin/Linux/Mac is attached.
Thanks for your patience on this.
Mark
Mattia Barbon wrote:
Mark Dootson wrote:
Hi,
Attached patch wraps classes wxOverlay and Wx::DCOverlay (from
overlay.h).
I was hunting around for a way to have temporary lines drawn on wxMAC
- e.g. drag the mouse and have a bounding rectangle drawn. ( you don't
get the logical functions to redraw back to the original on wxMAC).
I found that wxPython wraps these classes and they are just what you
need (on all platforms) if you are interested in drawing apps.
I think I'm doing the right thing with CLONE and DESTROY - but I'm not
so sure to commit directly.
The CLONE/DESTROY code looks ok to me, but please add a test to
t/15_threads.t before committing. It just needs to create 2 instances
of each class, undef the first instance before the thread is spawned and
let the second be cloned by thread creation.
Thanks!
Mattia
Index: GDI.xs
===================================================================
--- GDI.xs (revision 2774)
+++ GDI.xs (working copy)
@@ -45,6 +45,7 @@
INCLUDE: XS/Icon.xs
INCLUDE: XS/Cursor.xs
INCLUDE_COMMAND: $^X -MExtUtils::XSpp::Cmd -e xspp -- -t typemap.xsp XS/DC.xs
+INCLUDE: XS/Overlay.xs
INCLUDE: XS/Pen.xs
INCLUDE: XS/Brush.xs
INCLUDE: XS/Image.xs
Index: t/15_threads.t
===================================================================
--- t/15_threads.t (revision 2774)
+++ t/15_threads.t (working copy)
@@ -106,12 +106,21 @@
check_init { Wx::AcceleratorTable->new };
check_init { Wx::PlValidator->new };
+# Wx::Overlay / Wx::DCOverlay
+my $overlay1 = Wx::Overlay->new;
+my $overlay2 = Wx::Overlay->new;
+my $dcoverlay1 = Wx::DCOverlay->new($overlay1, Wx::ClientDC->new( $frame) );
+my $dcoverlay2 = Wx::DCOverlay->new($overlay2, Wx::ClientDC->new( $frame ) );
+undef $dcoverlay1;
+undef $overlay1;
+
# check the ref hash is safe!
undef $color2;
undef $pen2;
undef $imagelist2;
undef $bi2;
undef $tid2;
+
check_undef;
my $t = threads->create
( sub {
Index: typemap
===================================================================
--- typemap (revision 2774)
+++ typemap (working copy)
@@ -265,6 +265,8 @@
wxAutoBufferedPaintDC * O_WXOBJECT_THR
wxMirrorDC * O_WXOBJECT_THR
wxSVGFileDC * O_WXOBJECT_THR
+wxOverlay * O_NON_WXOBJECT
+wxDCOverlay * O_NON_WXOBJECT
wxDCClipper * O_NON_WXOBJECT_THR
wxTaskBarIcon * O_WXOBJECT
Index: typemap.tmpl
===================================================================
--- typemap.tmpl (revision 2774)
+++ typemap.tmpl (working copy)
@@ -265,6 +265,8 @@
wxAutoBufferedPaintDC * O_WXOBJECT_THR
wxMirrorDC * O_WXOBJECT_THR
wxSVGFileDC * O_WXOBJECT_THR
+wxOverlay * O_NON_WXOBJECT
+wxDCOverlay * O_NON_WXOBJECT
wxDCClipper * O_NON_WXOBJECT_THR
wxTaskBarIcon * O_WXOBJECT
Index: XS/Overlay.xs
===================================================================
--- XS/Overlay.xs (revision 0)
+++ XS/Overlay.xs (revision 0)
@@ -0,0 +1,76 @@
+#############################################################################
+## Name: XS/DC.xs
+## Purpose: XS for Wx::Overlay
+## Author: Mark Dootson
+## Modified by:
+## Created: 31/01/2010
+## RCS-ID: $Id: Overlay.xs 2561 2009-05-17 08:49:49Z mbarbon $
+## Copyright: (c) 2000-2007, 2010 Mattia Barbon
+## Licence: This program is free software; you can redistribute it and/or
+## modify it under the same terms as Perl itself
+#############################################################################
+
+#include <wx/dc.h>
+#include <wx/window.h>
+#include <wx/overlay.h>
+
+#if WXPERL_W_VERSION_GE( 2, 8, 0 )
+
+MODULE=Wx PACKAGE=Wx::Overlay
+
+wxOverlay*
+new( CLASS )
+ SV* CLASS
+ CODE:
+ RETVAL = new wxOverlay();
+ OUTPUT:
+ RETVAL
+
+void
+wxOverlay::Reset()
+
+
+MODULE=Wx PACKAGE=Wx::DCOverlay
+
+# DECLARE_OVERLOAD( woly, Wx::Overlay )
+
+wxDCOverlay*
+wxDCOverlay::new( ... )
+ PPCODE:
+ BEGIN_OVERLOAD()
+ MATCH_REDISP( wxPliOvl_woly_wdc, newDefault )
+ MATCH_REDISP( wxPliOvl_woly_wdc_n_n_n_n, newLong )
+ END_OVERLOAD( Wx::DCOverlay::new )
+
+wxDCOverlay*
+newDefault( CLASS, overlay, dc )
+ SV* CLASS
+ wxOverlay* overlay
+ wxWindowDC* dc
+ CODE:
+ RETVAL = new wxDCOverlay( *overlay, dc);
+ OUTPUT:
+ RETVAL
+
+wxDCOverlay*
+newLong( CLASS, overlay, dc, x, y, width, height )
+ SV* CLASS
+ wxOverlay* overlay
+ wxWindowDC* dc
+ int x
+ int y
+ int width
+ int height
+ CODE:
+ RETVAL = new wxDCOverlay( *overlay, dc, x, y, width, height);
+ OUTPUT:
+ RETVAL
+
+void
+wxDCOverlay::Clear()
+
+#endif
+
+
+
+