in reply to wxPreviewFrame error on closing
I have now compiled wxPerl with Alien::wxWidgets::Config::msw_2_8_10_uni_gcc_3_4.
I get an error before any windows are displayed
It occurs on this callFaulting application perl.exe, version 0.0.0.0, faulting module wx.dll +, version 0.0.0.0, fault address 0x0000342a.
This is likely a wxWidgets 2.8 specific bug$i_RTC_panel->{printout}->GetRichTextBuffer();
After removing that line I get same type of error after hitting preview
I believe this is also related to my version of wxwidgets, but I can't be sure. Bummer.Faulting application perl.exe, version 0.0.0.0, faulting module unknow +n, version 0.0.0.0, fault address 0xf0a8ca63.
So I went to see how wxperl_demo does it
After comparing that with samples/richtext/richtext.cpp...sub OnPreview { my( $this, $event ) = @_; my $prev = Wx::DemoModules::wxPrinting::Printout->new( $this->canvas +, "Preview" ); my $print = Wx::DemoModules::wxPrinting::Printout->new( $this->canva +s, "Print" ); my $preview = Wx::PrintPreview->new( $prev, $print ); my $frame = Wx::DemoModules::wxPrinting::PreviewFrame->new( $preview +, wxTheApp->GetTopWindow, "Printing Demo Preview", [-1, -1] +, [600, -1] ); $frame->Initialize(); $frame->Show( 1 ); }
I realize the problem with your code is that you're trying to share your printout object between your wxRichTextPrinting and wxPreviewFrame, and the docs confirm it
wxPreviewFrame::OnCloseWindowSo simply losing the wxRichTextPrinting object should work.Enables the other frames in the application, and deletes the print preview object, implicitly deleting any printout objects associated with the print preview object.
Actually, its probably only a partial fix
wxRichTextPrintout::SetRichTextBufferSets the buffer to print. wxRichTextPrintout does not manage this pointer; it should be managed by the calling code, such as wxRichTextPrinting.
I hope this works for you. If it doesn't you should use strace (or grind) to try to track down where the error occursBEGIN { package MyRichTextPrintout; use base qw[ Wx::RichTextPrintout ]; sub new { my ( $self, $buffer ) = @_; $self = $self->SUPER::new(); $self->SetRichTextBuffer($buffer); return $self; } sub DESTROY { $_[0]->SetRichTextBuffer(undef); return; } } sub on_click_richtext_preview { my ($self) = @_; my $preview = Wx::PrintPreview->new( MyRichTextPrintout->new( $self->{Ctl_Report_Text_Txt}->GetBuff +er() ), MyRichTextPrintout->new( $self->{Ctl_Report_Text_Txt}->GetBuff +er() ), ); $preview->SetZoom(200); my $frame = Wx::PreviewFrame->new( $preview, $self, "Printing Demo + Preview", wxDefaultPosition, [ 1360, 768 ], wxNO_BORDER ); $frame->Initialize(); my $state = $frame->Show(1); }
I gave it a shot but my wxwidgets/wxperl crashes after clicking preview (the window shows up and then the crash window on top of it), and I don't have a strace equivalent handy.
I couldn't compile wxPerl against Alien::wxWidgets::Config::msw_2_9_0_uni_gcc_3_4, maybe I'll try 2.8.11 some time later
Good luck
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: wxPreviewFrame error on closing
by Steve_BZ (Chaplain) on Sep 06, 2010 at 12:08 UTC | |
|
Re^2: wxPreviewFrame error on closing
by Steve_BZ (Chaplain) on Sep 08, 2010 at 21:14 UTC | |
by Anonymous Monk on Sep 09, 2010 at 01:39 UTC | |
by Steve_BZ (Chaplain) on Sep 09, 2010 at 18:16 UTC | |
by Anonymous Monk on Sep 09, 2010 at 20:43 UTC | |
|
Re^2: wxPreviewFrame error on closing
by Steve_BZ (Chaplain) on Sep 10, 2010 at 12:14 UTC | |
by Anonymous Monk on Sep 11, 2010 at 02:18 UTC |