added a test of a crash inside wxEVT_PAINT handler (this is a problem as it happens multiple times...)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34860 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -18,6 +18,7 @@
 | 
			
		||||
#include "wx/menu.h"
 | 
			
		||||
#include "wx/msgdlg.h"
 | 
			
		||||
#include "wx/button.h"
 | 
			
		||||
#include "wx/dcclient.h"
 | 
			
		||||
 | 
			
		||||
#include "wx/datetime.h"
 | 
			
		||||
#include "wx/ffile.h"
 | 
			
		||||
@@ -142,6 +143,7 @@ enum
 | 
			
		||||
    DebugRpt_Quit = wxID_EXIT,
 | 
			
		||||
    DebugRpt_Crash = 100,
 | 
			
		||||
    DebugRpt_Current,
 | 
			
		||||
    DebugRpt_Paint,
 | 
			
		||||
    DebugRpt_Upload,
 | 
			
		||||
    DebugRpt_About = wxID_ABOUT
 | 
			
		||||
};
 | 
			
		||||
@@ -155,9 +157,16 @@ private:
 | 
			
		||||
    void OnQuit(wxCommandEvent& event);
 | 
			
		||||
    void OnReportForCrash(wxCommandEvent& event);
 | 
			
		||||
    void OnReportForCurrent(wxCommandEvent& event);
 | 
			
		||||
    void OnReportPaint(wxCommandEvent& event);
 | 
			
		||||
    void OnReportUpload(wxCommandEvent& event);
 | 
			
		||||
    void OnAbout(wxCommandEvent& event);
 | 
			
		||||
 | 
			
		||||
    void OnPaint(wxPaintEvent& event);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // number of lines drawn in OnPaint()
 | 
			
		||||
    int m_numLines;
 | 
			
		||||
 | 
			
		||||
    DECLARE_NO_COPY_CLASS(MyFrame)
 | 
			
		||||
    DECLARE_EVENT_TABLE()
 | 
			
		||||
};
 | 
			
		||||
@@ -210,13 +219,18 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
 | 
			
		||||
    EVT_MENU(DebugRpt_Quit, MyFrame::OnQuit)
 | 
			
		||||
    EVT_MENU(DebugRpt_Crash, MyFrame::OnReportForCrash)
 | 
			
		||||
    EVT_MENU(DebugRpt_Current, MyFrame::OnReportForCurrent)
 | 
			
		||||
    EVT_MENU(DebugRpt_Paint, MyFrame::OnReportPaint)
 | 
			
		||||
    EVT_MENU(DebugRpt_Upload, MyFrame::OnReportUpload)
 | 
			
		||||
    EVT_MENU(DebugRpt_About, MyFrame::OnAbout)
 | 
			
		||||
 | 
			
		||||
    EVT_PAINT(MyFrame::OnPaint)
 | 
			
		||||
END_EVENT_TABLE()
 | 
			
		||||
 | 
			
		||||
MyFrame::MyFrame()
 | 
			
		||||
       : wxFrame(NULL, wxID_ANY, _T("wxWidgets Debug Report Sample"))
 | 
			
		||||
{
 | 
			
		||||
    m_numLines = 10;
 | 
			
		||||
 | 
			
		||||
    SetIcon(wxICON(sample));
 | 
			
		||||
 | 
			
		||||
    wxMenu *menuFile = new wxMenu;
 | 
			
		||||
@@ -227,6 +241,8 @@ MyFrame::MyFrame()
 | 
			
		||||
                       _T("Provoke a crash inside the program and create report for it"));
 | 
			
		||||
    menuReport->Append(DebugRpt_Current, _T("Report for c&urrent context\tCtrl-U"),
 | 
			
		||||
                       _T("Create report for the current program context"));
 | 
			
		||||
    menuReport->Append(DebugRpt_Paint, _T("Report for &paint handler\tCtrl-P"),
 | 
			
		||||
                       _T("Provoke a repeatable crash in wxEVT_PAINT handler"));
 | 
			
		||||
    menuReport->AppendSeparator();
 | 
			
		||||
    menuReport->AppendCheckItem(DebugRpt_Upload, _T("Up&load debug report"),
 | 
			
		||||
                       _T("You need to configure a web server accepting debug report uploads to use this function"));
 | 
			
		||||
@@ -264,6 +280,15 @@ void MyFrame::OnReportForCurrent(wxCommandEvent& WXUNUSED(event))
 | 
			
		||||
    wxGetApp().GenerateReport(wxDebugReport::Context_Current);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MyFrame::OnReportPaint(wxCommandEvent& WXUNUSED(event))
 | 
			
		||||
{
 | 
			
		||||
    // this will result in a crash in OnPaint()
 | 
			
		||||
    m_numLines = 0;
 | 
			
		||||
 | 
			
		||||
    // ensure it's called immediately
 | 
			
		||||
    Refresh();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MyFrame::OnReportUpload(wxCommandEvent& event)
 | 
			
		||||
{
 | 
			
		||||
    wxGetApp().UploadReport(event.IsChecked());
 | 
			
		||||
@@ -280,6 +305,14 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
 | 
			
		||||
    );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MyFrame::OnPaint(wxPaintEvent& WXUNUSED(event))
 | 
			
		||||
{
 | 
			
		||||
    wxPaintDC dc(this);
 | 
			
		||||
    const wxSize size = GetClientSize();
 | 
			
		||||
    for ( wxCoord x = 0; x < size.x; x += size.x/m_numLines )
 | 
			
		||||
        dc.DrawLine(x, 0, x, size.y);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ----------------------------------------------------------------------------
 | 
			
		||||
// MyApp
 | 
			
		||||
// ----------------------------------------------------------------------------
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user