If my code throws an exception on a function called by an event, the exception goes nowhere and the events of the app become disconnected.
For example, with this code on windows, on the first click on the "Test" button does nothing, but trying to click again on that button or the "Quit" one results in an error "Failed to call method: Quit()".
Also, when you close the frame, the exception is shown on the console.
class mainFrame extends wxFrame {
function __construct( $parent=null ){
parent::__construct ( $parent, wxID_ANY, wxEmptyString, wxDefaultPosition, new wxSize( 500,300 ), wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
$bSizer = new wxBoxSizer( wxVERTICAL );
$this->btn_test = new wxButton( $this, wxID_ANY, "TEST", wxDefaultPosition, new wxSize( -1,-1 ), 0 );
$this->btn_quit = new wxButton( $this, wxID_ANY, "QUIT", wxDefaultPosition, new wxSize( -1,-1 ), 0 );
$bSizer->Add( $this->btn_test, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 30 );
$bSizer->Add( $this->btn_quit, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 30 );
$this->SetSizer( $bSizer );
$this->btn_test->Connect( wxEVT_COMMAND_BUTTON_CLICKED, array($this, "testException") );
$this->btn_quit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, array($this, "Quit") );
}
function testException($event)
{
// This does nothing
throw new Exception('test');
$event->Skip();
}
function Quit()
{
$this->Destroy();
}
}
$mf = new mainFrame();
$mf->Show();
wxEntry();
HI,
If my code throws an exception on a function called by an event, the exception goes nowhere and the events of the app become disconnected.
For example, with this code on windows, on the first click on the "Test" button does nothing, but trying to click again on that button or the "Quit" one results in an error "Failed to call method: Quit()".
Also, when you close the frame, the exception is shown on the console.