patch from Dimitri fixing a few memory leaks and unTABbing the sources
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14660 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -196,12 +196,13 @@ void MyCanvas::OnPaint( wxPaintEvent &event )
|
|||||||
wxLogDebug( "size %d %d client_size %d %d", size.x, size.y, client_size.x, client_size.y );
|
wxLogDebug( "size %d %d client_size %d %d", size.x, size.y, client_size.x, client_size.y );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int i;
|
||||||
dc.SetPen( *wxWHITE_PEN );
|
dc.SetPen( *wxWHITE_PEN );
|
||||||
for (int i = 0; i < 20; i += 2)
|
for (i = 0; i < 20; i += 2)
|
||||||
dc.DrawLine( i,i, i+100,i );
|
dc.DrawLine( i,i, i+100,i );
|
||||||
|
|
||||||
dc.SetPen( *wxWHITE_PEN );
|
dc.SetPen( *wxWHITE_PEN );
|
||||||
for (int i = 200; i < 220; i += 2)
|
for (i = 200; i < 220; i += 2)
|
||||||
dc.DrawLine( i-200,i, i-100,i );
|
dc.DrawLine( i-200,i, i-100,i );
|
||||||
|
|
||||||
wxRegion region( 110, 110, 80, 80 );
|
wxRegion region( 110, 110, 80, 80 );
|
||||||
|
@@ -25,8 +25,10 @@ static const char sccsid[] = "%W% %G%";
|
|||||||
|
|
||||||
// Define a new application type
|
// Define a new application type
|
||||||
class MyApp: public wxApp
|
class MyApp: public wxApp
|
||||||
{ public:
|
{
|
||||||
bool OnInit(void);
|
public:
|
||||||
|
virtual bool OnInit(void);
|
||||||
|
virtual int OnExit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -154,8 +156,28 @@ bool MyApp::OnInit(void)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MyApp::OnExit()
|
||||||
|
{
|
||||||
|
if (cellBitmap1)
|
||||||
|
{
|
||||||
|
delete cellBitmap1;
|
||||||
|
cellBitmap1 = (wxBitmap *) NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cellBitmap2)
|
||||||
|
{
|
||||||
|
delete cellBitmap2;
|
||||||
|
cellBitmap1 = (wxBitmap *) NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// exit code is 0, everything is ok
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// My frame constructor
|
// My frame constructor
|
||||||
MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size):
|
MyFrame::MyFrame(wxFrame *frame, const wxString& title,
|
||||||
|
const wxPoint& pos, const wxSize& size):
|
||||||
wxFrame(frame, -1, title, pos, size)
|
wxFrame(frame, -1, title, pos, size)
|
||||||
{
|
{
|
||||||
grid = (wxGrid*) NULL;
|
grid = (wxGrid*) NULL;
|
||||||
@@ -197,6 +219,7 @@ void MyFrame::ToggleRowLabel(wxCommandEvent& WXUNUSED(event))
|
|||||||
grid->SetLabelSize(wxVERTICAL, 0);
|
grid->SetLabelSize(wxVERTICAL, 0);
|
||||||
else
|
else
|
||||||
grid->SetLabelSize(wxVERTICAL, 40);
|
grid->SetLabelSize(wxVERTICAL, 40);
|
||||||
|
|
||||||
grid->Refresh();
|
grid->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +229,7 @@ void MyFrame::ToggleColLabel(wxCommandEvent& WXUNUSED(event))
|
|||||||
grid->SetLabelSize(wxHORIZONTAL, 0);
|
grid->SetLabelSize(wxHORIZONTAL, 0);
|
||||||
else
|
else
|
||||||
grid->SetLabelSize(wxHORIZONTAL, 20);
|
grid->SetLabelSize(wxHORIZONTAL, 20);
|
||||||
|
|
||||||
grid->Refresh();
|
grid->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +239,8 @@ void MyFrame::ToggleDividers(wxCommandEvent& WXUNUSED(event))
|
|||||||
grid->SetDividerPen(wxPen(wxT("LIGHT GREY"), 1, wxSOLID));
|
grid->SetDividerPen(wxPen(wxT("LIGHT GREY"), 1, wxSOLID));
|
||||||
else
|
else
|
||||||
grid->SetDividerPen(wxNullPen);
|
grid->SetDividerPen(wxNullPen);
|
||||||
grid->Refresh();
|
|
||||||
|
grid->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFrame::LeftCell(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::LeftCell(wxCommandEvent& WXUNUSED(event))
|
||||||
|
@@ -44,9 +44,10 @@ class MyApp : public wxApp
|
|||||||
class MyFrame : public wxFrame
|
class MyFrame : public wxFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// ctor(s)
|
// ctor and dtor
|
||||||
|
|
||||||
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
|
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||||
|
virtual ~MyFrame();
|
||||||
|
|
||||||
// event handlers (these functions should _not_ be virtual)
|
// event handlers (these functions should _not_ be virtual)
|
||||||
void OnQuit(wxCommandEvent& event);
|
void OnQuit(wxCommandEvent& event);
|
||||||
@@ -185,12 +186,18 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
|||||||
m_Prn -> SetHeader(m_Name + "(@PAGENUM@/@PAGESCNT@)<hr>", wxPAGE_ALL);
|
m_Prn -> SetHeader(m_Name + "(@PAGENUM@/@PAGESCNT@)<hr>", wxPAGE_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// frame destructor
|
||||||
|
MyFrame::~MyFrame()
|
||||||
|
{
|
||||||
|
delete m_Prn;
|
||||||
|
m_Prn = (wxHtmlEasyPrinting *) NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// event handlers
|
// event handlers
|
||||||
|
|
||||||
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
delete m_Prn;
|
|
||||||
// TRUE is to force the frame to close
|
// TRUE is to force the frame to close
|
||||||
Close(TRUE);
|
Close(TRUE);
|
||||||
}
|
}
|
||||||
|
@@ -317,7 +317,8 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
|
|||||||
#if wxUSE_GIF
|
#if wxUSE_GIF
|
||||||
image.Destroy();
|
image.Destroy();
|
||||||
|
|
||||||
if ( !image.LoadFile( dir + wxString("horse.gif")) )
|
if ( !image.LoadFile( dir + wxString("horse.gif")))
|
||||||
|
//if ( !image.LoadFile( wxString("\\slidbar.gif"), wxBITMAP_TYPE_GIF, -2) )
|
||||||
wxLogError(wxT("Can't load GIF image"));
|
wxLogError(wxT("Can't load GIF image"));
|
||||||
else
|
else
|
||||||
my_horse_gif = new wxBitmap( image );
|
my_horse_gif = new wxBitmap( image );
|
||||||
@@ -430,6 +431,7 @@ MyCanvas::~MyCanvas()
|
|||||||
delete my_horse_ico32;
|
delete my_horse_ico32;
|
||||||
delete my_horse_ico16;
|
delete my_horse_ico16;
|
||||||
delete my_horse_ico;
|
delete my_horse_ico;
|
||||||
|
delete my_horse_cur;
|
||||||
delete my_smile_xbm;
|
delete my_smile_xbm;
|
||||||
delete my_square;
|
delete my_square;
|
||||||
delete my_anti;
|
delete my_anti;
|
||||||
|
@@ -60,7 +60,7 @@ char ipc_buffer[4000];
|
|||||||
wxListBox *the_list = NULL;
|
wxListBox *the_list = NULL;
|
||||||
|
|
||||||
MyConnection *the_connection = NULL;
|
MyConnection *the_connection = NULL;
|
||||||
MyClient *my_client ;
|
MyClient *my_client;
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
@@ -121,11 +121,17 @@ int MyApp::OnExit()
|
|||||||
if (the_connection)
|
if (the_connection)
|
||||||
{
|
{
|
||||||
the_connection->Disconnect();
|
the_connection->Disconnect();
|
||||||
|
delete the_connection;
|
||||||
|
the_connection = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// will delete the connection too
|
// will delete the connection too
|
||||||
|
// Update: Seems it didn't delete the_connection, because there's a leak.
|
||||||
|
// Deletion is now explicitly done a few lines up.
|
||||||
delete my_client;
|
delete my_client;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,11 +213,6 @@ MyConnection::MyConnection()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MyConnection::~MyConnection()
|
|
||||||
{
|
|
||||||
the_connection = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MyConnection::OnAdvise(const wxString& topic, const wxString& item, char *data, int size, wxIPCFormat format)
|
bool MyConnection::OnAdvise(const wxString& topic, const wxString& item, char *data, int size, wxIPCFormat format)
|
||||||
{
|
{
|
||||||
if (the_list)
|
if (the_list)
|
||||||
|
@@ -38,7 +38,6 @@ class MyConnection: public wxConnection
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyConnection();
|
MyConnection();
|
||||||
~MyConnection();
|
|
||||||
|
|
||||||
bool OnAdvise(const wxString& topic, const wxString& item, char *data, int size, wxIPCFormat format);
|
bool OnAdvise(const wxString& topic, const wxString& item, char *data, int size, wxIPCFormat format);
|
||||||
bool OnDisconnect();
|
bool OnDisconnect();
|
||||||
|
@@ -30,10 +30,11 @@
|
|||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/wx.h"
|
#include "wx/wx.h"
|
||||||
#include "wx/colordlg.h"
|
|
||||||
#include "wx/fontdlg.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "wx/colordlg.h"
|
||||||
|
#include "wx/fontdlg.h"
|
||||||
|
|
||||||
#include "wx/grid.h"
|
#include "wx/grid.h"
|
||||||
#include "wx/generic/gridctrl.h"
|
#include "wx/generic/gridctrl.h"
|
||||||
|
|
||||||
@@ -830,7 +831,6 @@ void GridFrame::OnEditorShown( wxGridEvent& ev )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxLogMessage( wxT("Cell editor shown.") );
|
wxLogMessage( wxT("Cell editor shown.") );
|
||||||
|
|
||||||
ev.Skip();
|
ev.Skip();
|
||||||
|
@@ -87,6 +87,16 @@ MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, cons
|
|||||||
canvas = (MyCanvas *) NULL;
|
canvas = (MyCanvas *) NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// frame destructor
|
||||||
|
MyFrame::~MyFrame()
|
||||||
|
{
|
||||||
|
if (g_TestBitmap)
|
||||||
|
{
|
||||||
|
delete g_TestBitmap;
|
||||||
|
g_TestBitmap = (wxBitmap *) NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
Close(TRUE);
|
Close(TRUE);
|
||||||
@@ -138,6 +148,7 @@ void MyFrame::OnLoadFile(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
if ( g_TestBitmap )
|
if ( g_TestBitmap )
|
||||||
delete g_TestBitmap;
|
delete g_TestBitmap;
|
||||||
|
|
||||||
g_TestBitmap = new wxBitmap(f, wxBITMAP_TYPE_PNG);
|
g_TestBitmap = new wxBitmap(f, wxBITMAP_TYPE_PNG);
|
||||||
if (!g_TestBitmap->Ok())
|
if (!g_TestBitmap->Ok())
|
||||||
{
|
{
|
||||||
|
@@ -31,6 +31,7 @@ class MyFrame: public wxFrame
|
|||||||
public:
|
public:
|
||||||
MyCanvas *canvas;
|
MyCanvas *canvas;
|
||||||
MyFrame(wxFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size);
|
MyFrame(wxFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||||
|
virtual ~MyFrame();
|
||||||
|
|
||||||
void OnActivate(bool) {}
|
void OnActivate(bool) {}
|
||||||
void OnLoadFile(wxCommandEvent& event);
|
void OnLoadFile(wxCommandEvent& event);
|
||||||
|
@@ -169,10 +169,12 @@ void MyApp::PropertyListTest(bool useDialog)
|
|||||||
wxStringList *strings2 = new wxStringList(wxT("earth"), wxT("fire"), wxT("wind"), wxT("water"), NULL);
|
wxStringList *strings2 = new wxStringList(wxT("earth"), wxT("fire"), wxT("wind"), wxT("water"), NULL);
|
||||||
sheet->AddProperty(new wxProperty("string list", strings2, "stringlist"));
|
sheet->AddProperty(new wxProperty("string list", strings2, "stringlist"));
|
||||||
|
|
||||||
wxPropertyListView *view =
|
wxPropertyListView *view = new wxPropertyListView
|
||||||
new wxPropertyListView(NULL,
|
(
|
||||||
wxPROP_BUTTON_OK | wxPROP_BUTTON_CANCEL |
|
NULL,
|
||||||
wxPROP_BUTTON_CHECK_CROSS|wxPROP_DYNAMIC_VALUE_FIELD|wxPROP_PULLDOWN|wxPROP_SHOWVALUES);
|
wxPROP_BUTTON_OK | wxPROP_BUTTON_CANCEL | wxPROP_BUTTON_CHECK_CROSS
|
||||||
|
|wxPROP_DYNAMIC_VALUE_FIELD|wxPROP_PULLDOWN|wxPROP_SHOWVALUES
|
||||||
|
);
|
||||||
|
|
||||||
wxDialog *propDialog = NULL;
|
wxDialog *propDialog = NULL;
|
||||||
wxPropertyListFrame *propFrame = NULL;
|
wxPropertyListFrame *propFrame = NULL;
|
||||||
@@ -224,6 +226,7 @@ void MyApp::PropertyFormTest(bool useDialog)
|
|||||||
|
|
||||||
wxDialog *propDialog = NULL;
|
wxDialog *propDialog = NULL;
|
||||||
wxPropertyFormFrame *propFrame = NULL;
|
wxPropertyFormFrame *propFrame = NULL;
|
||||||
|
|
||||||
if (useDialog)
|
if (useDialog)
|
||||||
{
|
{
|
||||||
propDialog = new PropFormDialog(view, NULL, "Property Form Test",
|
propDialog = new PropFormDialog(view, NULL, "Property Form Test",
|
||||||
@@ -232,8 +235,8 @@ void MyApp::PropertyFormTest(bool useDialog)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
propFrame = new PropFormFrame(view, NULL, "Property Form Test", wxPoint(-1,
|
propFrame = new PropFormFrame(view, NULL, "Property Form Test",
|
||||||
-1), wxSize(380, 250));
|
wxPoint(-1, -1), wxSize(380, 250));
|
||||||
propFrame->Initialize();
|
propFrame->Initialize();
|
||||||
m_childWindow = propFrame;
|
m_childWindow = propFrame;
|
||||||
}
|
}
|
||||||
@@ -242,7 +245,7 @@ void MyApp::PropertyFormTest(bool useDialog)
|
|||||||
wxWindow *panel ;
|
wxWindow *panel ;
|
||||||
if ( propDialog )
|
if ( propDialog )
|
||||||
{
|
{
|
||||||
panel = propDialog ;
|
panel = propDialog;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -333,8 +336,8 @@ void MyApp::PropertyFormTest(bool useDialog)
|
|||||||
c->width.AsIs();
|
c->width.AsIs();
|
||||||
slider->SetConstraints(c);
|
slider->SetConstraints(c);
|
||||||
|
|
||||||
wxListBox *listBox = new wxListBox(panel, -1, wxPoint(-1, -1), wxSize(200, 100),
|
wxListBox *listBox = new wxListBox(panel, -1, wxPoint(-1, -1),
|
||||||
0, NULL, 0, wxDefaultValidator, "constrained");
|
wxSize(200, 100), 0, NULL, 0, wxDefaultValidator, "constrained");
|
||||||
|
|
||||||
c = new wxLayoutConstraints;
|
c = new wxLayoutConstraints;
|
||||||
c->left.SameAs(panel, wxLeft, 4);
|
c->left.SameAs(panel, wxLeft, 4);
|
||||||
@@ -355,7 +358,9 @@ void MyApp::PropertyFormTest(bool useDialog)
|
|||||||
propDialog->Layout();
|
propDialog->Layout();
|
||||||
propDialog->Centre(wxBOTH);
|
propDialog->Centre(wxBOTH);
|
||||||
propDialog->Show(TRUE);
|
propDialog->Show(TRUE);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// panel->Layout();
|
// panel->Layout();
|
||||||
propFrame->Centre(wxBOTH);
|
propFrame->Centre(wxBOTH);
|
||||||
propFrame->Show(TRUE);
|
propFrame->Show(TRUE);
|
||||||
|
@@ -176,7 +176,7 @@ void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event) )
|
|||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
|
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
|
||||||
// EVT_BUTTON(RESOURCE_OK, MyDialog::OnOk)
|
//EVT_BUTTON(RESOURCE_OK, MyDialog::OnOk)
|
||||||
EVT_BUTTON(ID_BUTTON109, MyDialog::OnCancel)
|
EVT_BUTTON(ID_BUTTON109, MyDialog::OnCancel)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
@@ -831,7 +831,7 @@ Package=<4>
|
|||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
Project: "treectrl"=.\treectrl\treectrl.dsp - Package Owner=<4>
|
Project: "treetest"=.\treectrl\treetest.dsp - Package Owner=<4>
|
||||||
|
|
||||||
Package=<5>
|
Package=<5>
|
||||||
{{{
|
{{{
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "treelay.h"
|
#include "treelay.h"
|
||||||
|
|
||||||
wxTreeLayoutStored *myTree = NULL;
|
wxTreeLayoutStored *myTree = (wxTreeLayoutStored *) NULL;
|
||||||
|
|
||||||
// A macro needed for some compilers (AIX) that need 'main' to be defined
|
// A macro needed for some compilers (AIX) that need 'main' to be defined
|
||||||
// in the application itself.
|
// in the application itself.
|
||||||
@@ -85,6 +85,17 @@ bool MyApp::OnInit()
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MyApp::OnExit()
|
||||||
|
{
|
||||||
|
if (myTree)
|
||||||
|
{
|
||||||
|
delete myTree;
|
||||||
|
myTree = (wxTreeLayoutStored *) NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void MyApp::TreeTest(wxTreeLayoutStored& tree, wxDC& dc)
|
void MyApp::TreeTest(wxTreeLayoutStored& tree, wxDC& dc)
|
||||||
{
|
{
|
||||||
tree.Initialize(200);
|
tree.Initialize(200);
|
||||||
|
@@ -12,8 +12,9 @@
|
|||||||
// Define a new application
|
// Define a new application
|
||||||
class MyApp: public wxApp
|
class MyApp: public wxApp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool OnInit();
|
virtual bool OnInit();
|
||||||
|
virtual int OnExit();
|
||||||
void TreeTest(wxTreeLayoutStored& tree, wxDC& dc);
|
void TreeTest(wxTreeLayoutStored& tree, wxDC& dc);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user