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 );
|
||||
#endif
|
||||
|
||||
int i;
|
||||
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.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 );
|
||||
|
||||
wxRegion region( 110, 110, 80, 80 );
|
||||
|
@@ -25,8 +25,10 @@ static const char sccsid[] = "%W% %G%";
|
||||
|
||||
// Define a new application type
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
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)
|
||||
{
|
||||
grid = (wxGrid*) NULL;
|
||||
@@ -197,6 +219,7 @@ void MyFrame::ToggleRowLabel(wxCommandEvent& WXUNUSED(event))
|
||||
grid->SetLabelSize(wxVERTICAL, 0);
|
||||
else
|
||||
grid->SetLabelSize(wxVERTICAL, 40);
|
||||
|
||||
grid->Refresh();
|
||||
}
|
||||
|
||||
@@ -206,6 +229,7 @@ void MyFrame::ToggleColLabel(wxCommandEvent& WXUNUSED(event))
|
||||
grid->SetLabelSize(wxHORIZONTAL, 0);
|
||||
else
|
||||
grid->SetLabelSize(wxHORIZONTAL, 20);
|
||||
|
||||
grid->Refresh();
|
||||
}
|
||||
|
||||
@@ -215,7 +239,8 @@ void MyFrame::ToggleDividers(wxCommandEvent& WXUNUSED(event))
|
||||
grid->SetDividerPen(wxPen(wxT("LIGHT GREY"), 1, wxSOLID));
|
||||
else
|
||||
grid->SetDividerPen(wxNullPen);
|
||||
grid->Refresh();
|
||||
|
||||
grid->Refresh();
|
||||
}
|
||||
|
||||
void MyFrame::LeftCell(wxCommandEvent& WXUNUSED(event))
|
||||
|
@@ -44,9 +44,10 @@ class MyApp : public wxApp
|
||||
class MyFrame : public wxFrame
|
||||
{
|
||||
public:
|
||||
// ctor(s)
|
||||
// ctor and dtor
|
||||
|
||||
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||
virtual ~MyFrame();
|
||||
|
||||
// event handlers (these functions should _not_ be virtual)
|
||||
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);
|
||||
}
|
||||
|
||||
// frame destructor
|
||||
MyFrame::~MyFrame()
|
||||
{
|
||||
delete m_Prn;
|
||||
m_Prn = (wxHtmlEasyPrinting *) NULL;
|
||||
}
|
||||
|
||||
|
||||
// event handlers
|
||||
|
||||
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
delete m_Prn;
|
||||
// TRUE is to force the frame to close
|
||||
Close(TRUE);
|
||||
}
|
||||
|
@@ -317,7 +317,8 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
|
||||
#if wxUSE_GIF
|
||||
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"));
|
||||
else
|
||||
my_horse_gif = new wxBitmap( image );
|
||||
@@ -430,6 +431,7 @@ MyCanvas::~MyCanvas()
|
||||
delete my_horse_ico32;
|
||||
delete my_horse_ico16;
|
||||
delete my_horse_ico;
|
||||
delete my_horse_cur;
|
||||
delete my_smile_xbm;
|
||||
delete my_square;
|
||||
delete my_anti;
|
||||
|
@@ -60,7 +60,7 @@ char ipc_buffer[4000];
|
||||
wxListBox *the_list = NULL;
|
||||
|
||||
MyConnection *the_connection = NULL;
|
||||
MyClient *my_client ;
|
||||
MyClient *my_client;
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
@@ -121,11 +121,17 @@ int MyApp::OnExit()
|
||||
if (the_connection)
|
||||
{
|
||||
the_connection->Disconnect();
|
||||
delete the_connection;
|
||||
the_connection = NULL;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
if (the_list)
|
||||
|
@@ -38,7 +38,6 @@ class MyConnection: public wxConnection
|
||||
{
|
||||
public:
|
||||
MyConnection();
|
||||
~MyConnection();
|
||||
|
||||
bool OnAdvise(const wxString& topic, const wxString& item, char *data, int size, wxIPCFormat format);
|
||||
bool OnDisconnect();
|
||||
|
@@ -30,10 +30,11 @@
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#include "wx/colordlg.h"
|
||||
#include "wx/fontdlg.h"
|
||||
#endif
|
||||
|
||||
#include "wx/colordlg.h"
|
||||
#include "wx/fontdlg.h"
|
||||
|
||||
#include "wx/grid.h"
|
||||
#include "wx/generic/gridctrl.h"
|
||||
|
||||
@@ -830,7 +831,6 @@ void GridFrame::OnEditorShown( wxGridEvent& ev )
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
wxLogMessage( wxT("Cell editor shown.") );
|
||||
|
||||
ev.Skip();
|
||||
|
@@ -87,6 +87,16 @@ MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, cons
|
||||
canvas = (MyCanvas *) NULL;
|
||||
}
|
||||
|
||||
// frame destructor
|
||||
MyFrame::~MyFrame()
|
||||
{
|
||||
if (g_TestBitmap)
|
||||
{
|
||||
delete g_TestBitmap;
|
||||
g_TestBitmap = (wxBitmap *) NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Close(TRUE);
|
||||
@@ -138,6 +148,7 @@ void MyFrame::OnLoadFile(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
if ( g_TestBitmap )
|
||||
delete g_TestBitmap;
|
||||
|
||||
g_TestBitmap = new wxBitmap(f, wxBITMAP_TYPE_PNG);
|
||||
if (!g_TestBitmap->Ok())
|
||||
{
|
||||
|
@@ -31,6 +31,7 @@ class MyFrame: public wxFrame
|
||||
public:
|
||||
MyCanvas *canvas;
|
||||
MyFrame(wxFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||
virtual ~MyFrame();
|
||||
|
||||
void OnActivate(bool) {}
|
||||
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);
|
||||
sheet->AddProperty(new wxProperty("string list", strings2, "stringlist"));
|
||||
|
||||
wxPropertyListView *view =
|
||||
new wxPropertyListView(NULL,
|
||||
wxPROP_BUTTON_OK | wxPROP_BUTTON_CANCEL |
|
||||
wxPROP_BUTTON_CHECK_CROSS|wxPROP_DYNAMIC_VALUE_FIELD|wxPROP_PULLDOWN|wxPROP_SHOWVALUES);
|
||||
wxPropertyListView *view = new wxPropertyListView
|
||||
(
|
||||
NULL,
|
||||
wxPROP_BUTTON_OK | wxPROP_BUTTON_CANCEL | wxPROP_BUTTON_CHECK_CROSS
|
||||
|wxPROP_DYNAMIC_VALUE_FIELD|wxPROP_PULLDOWN|wxPROP_SHOWVALUES
|
||||
);
|
||||
|
||||
wxDialog *propDialog = NULL;
|
||||
wxPropertyListFrame *propFrame = NULL;
|
||||
@@ -224,6 +226,7 @@ void MyApp::PropertyFormTest(bool useDialog)
|
||||
|
||||
wxDialog *propDialog = NULL;
|
||||
wxPropertyFormFrame *propFrame = NULL;
|
||||
|
||||
if (useDialog)
|
||||
{
|
||||
propDialog = new PropFormDialog(view, NULL, "Property Form Test",
|
||||
@@ -232,8 +235,8 @@ void MyApp::PropertyFormTest(bool useDialog)
|
||||
}
|
||||
else
|
||||
{
|
||||
propFrame = new PropFormFrame(view, NULL, "Property Form Test", wxPoint(-1,
|
||||
-1), wxSize(380, 250));
|
||||
propFrame = new PropFormFrame(view, NULL, "Property Form Test",
|
||||
wxPoint(-1, -1), wxSize(380, 250));
|
||||
propFrame->Initialize();
|
||||
m_childWindow = propFrame;
|
||||
}
|
||||
@@ -242,7 +245,7 @@ void MyApp::PropertyFormTest(bool useDialog)
|
||||
wxWindow *panel ;
|
||||
if ( propDialog )
|
||||
{
|
||||
panel = propDialog ;
|
||||
panel = propDialog;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -333,8 +336,8 @@ void MyApp::PropertyFormTest(bool useDialog)
|
||||
c->width.AsIs();
|
||||
slider->SetConstraints(c);
|
||||
|
||||
wxListBox *listBox = new wxListBox(panel, -1, wxPoint(-1, -1), wxSize(200, 100),
|
||||
0, NULL, 0, wxDefaultValidator, "constrained");
|
||||
wxListBox *listBox = new wxListBox(panel, -1, wxPoint(-1, -1),
|
||||
wxSize(200, 100), 0, NULL, 0, wxDefaultValidator, "constrained");
|
||||
|
||||
c = new wxLayoutConstraints;
|
||||
c->left.SameAs(panel, wxLeft, 4);
|
||||
@@ -355,7 +358,9 @@ void MyApp::PropertyFormTest(bool useDialog)
|
||||
propDialog->Layout();
|
||||
propDialog->Centre(wxBOTH);
|
||||
propDialog->Show(TRUE);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// panel->Layout();
|
||||
propFrame->Centre(wxBOTH);
|
||||
propFrame->Show(TRUE);
|
||||
|
@@ -176,7 +176,7 @@ void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event) )
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
|
||||
// EVT_BUTTON(RESOURCE_OK, MyDialog::OnOk)
|
||||
//EVT_BUTTON(RESOURCE_OK, MyDialog::OnOk)
|
||||
EVT_BUTTON(ID_BUTTON109, MyDialog::OnCancel)
|
||||
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>
|
||||
{{{
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "treelay.h"
|
||||
|
||||
wxTreeLayoutStored *myTree = NULL;
|
||||
wxTreeLayoutStored *myTree = (wxTreeLayoutStored *) NULL;
|
||||
|
||||
// A macro needed for some compilers (AIX) that need 'main' to be defined
|
||||
// in the application itself.
|
||||
@@ -85,6 +85,17 @@ bool MyApp::OnInit()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int MyApp::OnExit()
|
||||
{
|
||||
if (myTree)
|
||||
{
|
||||
delete myTree;
|
||||
myTree = (wxTreeLayoutStored *) NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MyApp::TreeTest(wxTreeLayoutStored& tree, wxDC& dc)
|
||||
{
|
||||
tree.Initialize(200);
|
||||
|
@@ -12,8 +12,9 @@
|
||||
// Define a new application
|
||||
class MyApp: public wxApp
|
||||
{
|
||||
public:
|
||||
bool OnInit();
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
virtual int OnExit();
|
||||
void TreeTest(wxTreeLayoutStored& tree, wxDC& dc);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user