I totally missed that I needed https://wxperl.svn.sourceforge.net/svnroot/wxperl/wxPerl/trunk to try to help :)

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

Faulting application perl.exe, version 0.0.0.0, faulting module wx.dll +, version 0.0.0.0, fault address 0x0000342a.
It occurs on this call
$i_RTC_panel->{printout}->GetRichTextBuffer();
This is likely a wxWidgets 2.8 specific bug

After removing that line I get same type of error after hitting preview

Faulting application perl.exe, version 0.0.0.0, faulting module unknow +n, version 0.0.0.0, fault address 0xf0a8ca63.
I believe this is also related to my version of wxwidgets, but I can't be sure. Bummer.

So I went to see how wxperl_demo does it

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 ); }
After comparing that with samples/richtext/richtext.cpp...

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::OnCloseWindow

Enables the other frames in the application, and deletes the print preview object, implicitly deleting any printout objects associated with the print preview object.

So simply losing the wxRichTextPrinting object should work.

Actually, its probably only a partial fix

wxRichTextPrintout::SetRichTextBuffer

Sets the buffer to print. wxRichTextPrintout does not manage this pointer; it should be managed by the calling code, such as wxRichTextPrinting.

So you'll probably have to subclass wxRichTextPrinting like
BEGIN { 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 hope this works for you. If it doesn't you should use strace (or grind) to try to track down where the error occurs

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


In reply to Re: wxPreviewFrame error on closing by Anonymous Monk
in thread wxPreviewFrame error on closing by Steve_BZ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.