Test crashing in wxEVT_TIMER handler too in debugrpt sample.
This test was useful to verify that we don't need a __try/__catch block around the code processing WM_TIMER as it's not called from the kernel and so doesn't suffer from the same problem as WM_PAINT, i.e. exceptions happening inside wxEVT_TIMER handlers are caught without problems. See #16656.
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
#include "wx/msgdlg.h"
|
#include "wx/msgdlg.h"
|
||||||
#include "wx/button.h"
|
#include "wx/button.h"
|
||||||
#include "wx/dcclient.h"
|
#include "wx/dcclient.h"
|
||||||
|
#include "wx/timer.h"
|
||||||
|
|
||||||
#include "wx/datetime.h"
|
#include "wx/datetime.h"
|
||||||
#include "wx/ffile.h"
|
#include "wx/ffile.h"
|
||||||
@@ -145,6 +146,7 @@ enum
|
|||||||
DebugRpt_Crash = 100,
|
DebugRpt_Crash = 100,
|
||||||
DebugRpt_Current,
|
DebugRpt_Current,
|
||||||
DebugRpt_Paint,
|
DebugRpt_Paint,
|
||||||
|
DebugRpt_Timer,
|
||||||
DebugRpt_Upload,
|
DebugRpt_Upload,
|
||||||
DebugRpt_About = wxID_ABOUT
|
DebugRpt_About = wxID_ABOUT
|
||||||
};
|
};
|
||||||
@@ -159,11 +161,23 @@ private:
|
|||||||
void OnReportForCrash(wxCommandEvent& event);
|
void OnReportForCrash(wxCommandEvent& event);
|
||||||
void OnReportForCurrent(wxCommandEvent& event);
|
void OnReportForCurrent(wxCommandEvent& event);
|
||||||
void OnReportPaint(wxCommandEvent& event);
|
void OnReportPaint(wxCommandEvent& event);
|
||||||
|
void OnReportTimer(wxCommandEvent& event);
|
||||||
void OnReportUpload(wxCommandEvent& event);
|
void OnReportUpload(wxCommandEvent& event);
|
||||||
void OnAbout(wxCommandEvent& event);
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
|
|
||||||
|
// a timer whose only purpose in life is to crash as soon as it's started
|
||||||
|
class BadTimer : public wxTimer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BadTimer() { }
|
||||||
|
|
||||||
|
virtual void Notify() wxOVERRIDE
|
||||||
|
{
|
||||||
|
foo(8);
|
||||||
|
}
|
||||||
|
} m_badTimer;
|
||||||
|
|
||||||
// number of lines drawn in OnPaint()
|
// number of lines drawn in OnPaint()
|
||||||
int m_numLines;
|
int m_numLines;
|
||||||
@@ -221,6 +235,7 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_MENU(DebugRpt_Crash, MyFrame::OnReportForCrash)
|
EVT_MENU(DebugRpt_Crash, MyFrame::OnReportForCrash)
|
||||||
EVT_MENU(DebugRpt_Current, MyFrame::OnReportForCurrent)
|
EVT_MENU(DebugRpt_Current, MyFrame::OnReportForCurrent)
|
||||||
EVT_MENU(DebugRpt_Paint, MyFrame::OnReportPaint)
|
EVT_MENU(DebugRpt_Paint, MyFrame::OnReportPaint)
|
||||||
|
EVT_MENU(DebugRpt_Timer, MyFrame::OnReportTimer)
|
||||||
EVT_MENU(DebugRpt_Upload, MyFrame::OnReportUpload)
|
EVT_MENU(DebugRpt_Upload, MyFrame::OnReportUpload)
|
||||||
EVT_MENU(DebugRpt_About, MyFrame::OnAbout)
|
EVT_MENU(DebugRpt_About, MyFrame::OnAbout)
|
||||||
|
|
||||||
@@ -245,6 +260,8 @@ MyFrame::MyFrame()
|
|||||||
wxT("Create report for the current program context"));
|
wxT("Create report for the current program context"));
|
||||||
menuReport->Append(DebugRpt_Paint, wxT("Report for &paint handler\tCtrl-P"),
|
menuReport->Append(DebugRpt_Paint, wxT("Report for &paint handler\tCtrl-P"),
|
||||||
wxT("Provoke a repeatable crash in wxEVT_PAINT handler"));
|
wxT("Provoke a repeatable crash in wxEVT_PAINT handler"));
|
||||||
|
menuReport->Append(DebugRpt_Timer, wxT("Report for &timer handler\tCtrl-T"),
|
||||||
|
wxT("Provoke a crash in wxEVT_TIMER handler"));
|
||||||
menuReport->AppendSeparator();
|
menuReport->AppendSeparator();
|
||||||
menuReport->AppendCheckItem(DebugRpt_Upload, wxT("Up&load debug report"),
|
menuReport->AppendCheckItem(DebugRpt_Upload, wxT("Up&load debug report"),
|
||||||
wxT("You need to configure a web server accepting debug report uploads to use this function"));
|
wxT("You need to configure a web server accepting debug report uploads to use this function"));
|
||||||
@@ -291,6 +308,12 @@ void MyFrame::OnReportPaint(wxCommandEvent& WXUNUSED(event))
|
|||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnReportTimer(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
// this will result in a crash in BadTimer::OnNotify() soon
|
||||||
|
m_badTimer.StartOnce(100);
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnReportUpload(wxCommandEvent& event)
|
void MyFrame::OnReportUpload(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxGetApp().UploadReport(event.IsChecked());
|
wxGetApp().UploadReport(event.IsChecked());
|
||||||
|
Reference in New Issue
Block a user