in reply to wxPreviewFrame error on closing

I don't have a running Wx available, but it sounds similar to a basic fine point in Gtk2. Since it's likely that your Wx build is based on the Gtk2 libs, I will mention it. You may have some confusion between the signal handlers between the "destroy" and "delete_event". An explanation by muppet is below.
> my $window => Gtk2::Window -> new; > $window -> signal_connect ( 'delete_event', sub { Gtk2 -> main_quit; + } ); Connect this to 'destroy' instead of 'delete-event'. The handler for 'delete-event' is supposed to return a boolean value saying "i handled + this" or "i didn't handle this", that is typically used to inhibit destructi +on of the window. You're not doing that, though. The default action from 'delete-event' is to destroy the window, which will cause the 'destroy +' event to fire. Of course, you can also get 'destroy' from other places in y +our program. So, if you connect the quit of the main loop to the main win +dow's 'destroy' rather than 'delete-event', you get a more robust program.
and here is a Gtk2 example which demonstrates the difference between delete and destroy. The delete_event is what is connected to the window manager's Close button. It sounds like you may need to intercept one of those signals in Wx.
#!/usr/bin/perl use warnings; use strict; use Gtk2 -init; my $window = Gtk2::Window->new; $window->add( Gtk2::Label->new("I'm a banana!") ); $window->show_all; $window->signal_connect( delete_event => sub { return !ask( $_[0], "Really quit?" ); } ); $window->signal_connect( destroy => sub { Gtk2->main_quit } ); Gtk2->main; sub ask { my ( $parent, $question ) = @_; my $msgbox = Gtk2::MessageDialog->new( $parent, [], 'question', 'yes-no', $qu +estion ); my $response = $msgbox->run(); $msgbox->destroy; return $response eq 'yes'; }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: wxPreviewFrame error on closing
by Steve_BZ (Chaplain) on Aug 31, 2010 at 10:37 UTC

    Hi flash japh,

    Thanks so much for your response.

    I guess it's possible that this is the case, but if so it's outside my remit and I'd have to post it to the wxWidgets website. The destroy is handled automatically by the underlying wxWidgets c-code. wxPreviewFrame works fine with a wxPrintout object but not with a wxRichTextPrintout object - or at least my version of it.

    I guess I'd have to write a test to prove that your theory one way or the other. ANy ideas how I might do this?

    Thanks again.

    Have a good day.

    Steve

      ANy ideas how I might do this?

      Sorry, I don't do well with the OO style of Wx. The Wx maillinglist is probably your best bet.


      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh

        Hi flash japh,

        I may have to do that, but I'm not ready to give up quite yet :)

        Regards

        Steve