Allow memcheck.cpp to be compiled without wxDebugContext (for e.g. testing
using other leak checkers). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30828 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
// Normally, new is automatically defined to be the
|
// Normally, new is automatically defined to be the
|
||||||
// debugging version. If not, this does it.
|
// debugging version. If not, this does it.
|
||||||
#if !defined(new) && defined(WXDEBUG_NEW)
|
#if !defined(new) && defined(WXDEBUG_NEW) && wxUSE_DEBUG_CONTEXT
|
||||||
#define new WXDEBUG_NEW
|
#define new WXDEBUG_NEW
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -83,7 +83,16 @@ bool MyApp::OnInit(void)
|
|||||||
// Show the frame
|
// Show the frame
|
||||||
frame->Show(TRUE);
|
frame->Show(TRUE);
|
||||||
|
|
||||||
|
#if wxUSE_DEBUG_CONTEXT
|
||||||
wxDebugContext::SetCheckpoint();
|
wxDebugContext::SetCheckpoint();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// object allocation
|
||||||
|
wxBrush* brush = new wxBrush(*wxRED);
|
||||||
|
wxBitmap* bitmap = new wxBitmap(100, 100);
|
||||||
|
|
||||||
|
// non-object allocation
|
||||||
|
char *ordinaryNonObject = new char[1000];
|
||||||
|
|
||||||
wxString *thing = new wxString;
|
wxString *thing = new wxString;
|
||||||
|
|
||||||
@@ -91,11 +100,9 @@ bool MyApp::OnInit(void)
|
|||||||
wxDateTime* date = new wxDateTime;
|
wxDateTime* date = new wxDateTime;
|
||||||
#endif // wxUSE_DATETIME
|
#endif // wxUSE_DATETIME
|
||||||
|
|
||||||
// non-object allocation
|
|
||||||
char *ordinaryNonObject = new char[1000];
|
|
||||||
|
|
||||||
const char *data = (const char*) thing ;
|
const char *data = (const char*) thing ;
|
||||||
|
|
||||||
|
#if wxUSE_DEBUG_CONTEXT
|
||||||
// On MSW, Dump() crashes if using wxLogGui,
|
// On MSW, Dump() crashes if using wxLogGui,
|
||||||
// so use wxLogStderr instead.
|
// so use wxLogStderr instead.
|
||||||
wxLog* oldLog = wxLog::SetActiveTarget(new wxLogStderr);
|
wxLog* oldLog = wxLog::SetActiveTarget(new wxLogStderr);
|
||||||
@@ -106,6 +113,7 @@ bool MyApp::OnInit(void)
|
|||||||
|
|
||||||
// Set back to wxLogGui
|
// Set back to wxLogGui
|
||||||
delete wxLog::SetActiveTarget(oldLog);
|
delete wxLog::SetActiveTarget(oldLog);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Don't delete these objects, to force wxApp to flag a memory leak.
|
// Don't delete these objects, to force wxApp to flag a memory leak.
|
||||||
// delete thing;
|
// delete thing;
|
||||||
|
Reference in New Issue
Block a user