Override OnAssertFailure() and not deprecated OnAssert() in except sample.
Also make the overridden version more interesting instead of just calling the base class method from it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62840 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -91,14 +91,13 @@ public:
|
|||||||
// crash (e.g. dereferencing null pointer, division by 0, ...)
|
// crash (e.g. dereferencing null pointer, division by 0, ...)
|
||||||
virtual void OnFatalException();
|
virtual void OnFatalException();
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
// you can override this function to do something different (e.g. log the
|
||||||
// in debug mode, you can override this function to do something different
|
// assert to file) whenever an assertion fails
|
||||||
// (e.g. log the assert to file) whenever an assertion fails
|
virtual void OnAssertFailure(const wxChar *file,
|
||||||
virtual void OnAssert(const wxChar *file,
|
int line,
|
||||||
int line,
|
const wxChar *func,
|
||||||
const wxChar *cond,
|
const wxChar *cond,
|
||||||
const wxChar *msg);
|
const wxChar *msg);
|
||||||
#endif // __WXDEBUG__
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Define a new frame type: this is going to be our main frame
|
// Define a new frame type: this is going to be our main frame
|
||||||
@@ -302,19 +301,25 @@ void MyApp::OnFatalException()
|
|||||||
wxT("wxExcept Sample"), wxOK | wxICON_ERROR);
|
wxT("wxExcept Sample"), wxOK | wxICON_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
void MyApp::OnAssertFailure(const wxChar *file,
|
||||||
|
int line,
|
||||||
void MyApp::OnAssert(const wxChar *file,
|
const wxChar *func,
|
||||||
int line,
|
const wxChar *cond,
|
||||||
const wxChar *cond,
|
const wxChar *msg)
|
||||||
const wxChar *msg)
|
|
||||||
{
|
{
|
||||||
// we don't have anything special to do here
|
if ( wxMessageBox
|
||||||
wxApp::OnAssert(file, line, cond, msg);
|
(
|
||||||
|
wxString::Format("An assert failed in %s().", func) +
|
||||||
|
"\n"
|
||||||
|
"Do you want to call the default assert handler?",
|
||||||
|
"wxExcept Sample",
|
||||||
|
wxYES_NO | wxICON_QUESTION
|
||||||
|
) == wxYES )
|
||||||
|
{
|
||||||
|
wxApp::OnAssertFailure(file, line, func, cond, msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __WXDEBUG__
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// MyFrame implementation
|
// MyFrame implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
Reference in New Issue
Block a user