in reply to Wx::AuiManager faulting module wxbase294u_gcc_citrusperl.dll, version 2.9.4.0, fault address 0x001d52da.
Well, I figured it out, $m_mgr goes out of scope, but needs to be kept alive, so this fixes it
$m_mgr->Update(); $this->{m_mgr} = $m_mgr ; } $this->Show; ## memory access violation here NO MORE $app->MainLoop; $this->{m_mgr}->UnInit(); ## without this its fault address 0x001d4d91 +.
Subclassing a frame like the original example works better
Final example
#!/usr/bin/perl -- use strict; use warnings; use Wx; use Wx::AUI; ### http://wiki.wxwidgets.org/WxAUI my $app = Wx::SimpleApp->new; my $myframe = MyFrame->new( undef, -1, "myframe3", [ -1, -1 ], [ -1, -1 ], Wx::wxDEFAULT_FRAME_STYLE() | Wx::wxTAB_TRAVERSAL() ); $myframe->Show; $app->MainLoop; BEGIN { package MyFrame; use base qw/ Wx::Frame /; use Wx::Locale( gettext => 'wxT' ); sub new { my $class = shift; my $this = $class->SUPER::new(@_); my $m_mgr = Wx::AuiManager->new(); ## // notify wxAUI which frame to use $m_mgr->SetManagedWindow($this); ## // create several text controls my $text1 = Wx::TextCtrl->new( $this, -1, wxT("Pane 1 - sample text"), Wx::wxDefaultPosition(), Wx::Size->new( ( 200, 150 ) ), Wx::wxNO_BORDER() | Wx::wxTE_MULTILINE() ); my $text2 = Wx::TextCtrl->new( $this, -1, wxT("Pane 2 - sample text"), Wx::wxDefaultPosition(), Wx::Size->new( ( 200, 150 ) ), Wx::wxNO_BORDER() | Wx::wxTE_MULTILINE() ); my $text3 = Wx::TextCtrl->new( $this, -1, wxT("Main content window"), Wx::wxDefaultPosition(), Wx::Size->new( ( 200, 150 ) ), Wx::wxNO_BORDER() | Wx::wxTE_MULTILINE() ); ## // add the panes to the manager $m_mgr->AddPane( $text1, Wx::wxLEFT(), wxT("Pane Number One" +) ); $m_mgr->AddPane( $text2, Wx::wxBOTTOM(), wxT("Pane Number Two" +) ); $m_mgr->AddPane( $text3, Wx::wxCENTER(), "" ); ## same as above #~ $m_mgr->AddPane( $text1, Wx::AuiPaneInfo->new->Name( "Pane Numb +er One" )->Left->Position( 1 )->Resizable ); #~ $m_mgr->AddPane( $text2, Wx::AuiPaneInfo->new->Name( "Pane Numb +er Two" )->Bottom->Position( 1 )->Resizable ); #~ $m_mgr->AddPane( $text3, Wx::AuiPaneInfo->new->Name( "Pane Numb +er Three" )->CenterPane->Position( 1 )->Resizable ); ## // tell the manager to "commit" all the changes just made $m_mgr->Update(); $this->{m_mgr} = $m_mgr; return $this; } sub DESTROY { shift()->{m_mgr}->UnInit(); } }
|
|---|