prevent a reference leak when OOR objects are created

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28281 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-07-17 17:52:29 +00:00
parent 251f47d1ea
commit a77bf68f69
5 changed files with 51 additions and 30 deletions

View File

@@ -89,6 +89,7 @@ public:
void _setCallbackInfo(PyObject* self, PyObject* _class); void _setCallbackInfo(PyObject* self, PyObject* _class);
%extend { %extend {
void _setOORInfo(PyObject* _self) { void _setOORInfo(PyObject* _self) {
if (!self->GetClientObject())
self->SetClientObject(new wxPyOORClientData(_self)); self->SetClientObject(new wxPyOORClientData(_self));
} }
} }

View File

@@ -69,6 +69,7 @@ public:
%extend { %extend {
void _setOORInfo(PyObject* _self) { void _setOORInfo(PyObject* _self) {
if (_self && _self != Py_None) { if (_self && _self != Py_None) {
if (!self->GetClientObject())
self->SetClientObject(new wxPyOORClientData(_self)); self->SetClientObject(new wxPyOORClientData(_self));
} }
else { else {

View File

@@ -14,6 +14,16 @@
%rename(GRID_VALUE_DATETIME) wxGRID_VALUE_DATETIME; %rename(GRID_VALUE_DATETIME) wxGRID_VALUE_DATETIME;
%rename(GridNoCellCoords) wxGridNoCellCoords; %rename(GridNoCellCoords) wxGridNoCellCoords;
%rename(GridNoCellRect) wxGridNoCellRect; %rename(GridNoCellRect) wxGridNoCellRect;
%rename(GRID_DEFAULT_NUMBER_ROWS) wxGRID_DEFAULT_NUMBER_ROWS;
%rename(GRID_DEFAULT_NUMBER_COLS) wxGRID_DEFAULT_NUMBER_COLS;
%rename(GRID_DEFAULT_ROW_HEIGHT) wxGRID_DEFAULT_ROW_HEIGHT;
%rename(GRID_DEFAULT_COL_WIDTH) wxGRID_DEFAULT_COL_WIDTH;
%rename(GRID_DEFAULT_COL_LABEL_HEIGHT) wxGRID_DEFAULT_COL_LABEL_HEIGHT;
%rename(GRID_DEFAULT_ROW_LABEL_WIDTH) wxGRID_DEFAULT_ROW_LABEL_WIDTH;
%rename(GRID_LABEL_EDGE_ZONE) wxGRID_LABEL_EDGE_ZONE;
%rename(GRID_MIN_ROW_HEIGHT) wxGRID_MIN_ROW_HEIGHT;
%rename(GRID_MIN_COL_WIDTH) wxGRID_MIN_COL_WIDTH;
%rename(GRID_DEFAULT_SCROLLBAR_WIDTH) wxGRID_DEFAULT_SCROLLBAR_WIDTH;
%rename(GridCellRenderer) wxGridCellRenderer; %rename(GridCellRenderer) wxGridCellRenderer;
%rename(PyGridCellRenderer) wxPyGridCellRenderer; %rename(PyGridCellRenderer) wxPyGridCellRenderer;
%rename(GridCellStringRenderer) wxGridCellStringRenderer; %rename(GridCellStringRenderer) wxGridCellStringRenderer;

View File

@@ -372,6 +372,7 @@ public:
%extend { %extend {
void _setOORInfo(PyObject* _self) { void _setOORInfo(PyObject* _self) {
if (!self->GetClientObject())
self->SetClientObject(new wxPyOORClientData(_self)); self->SetClientObject(new wxPyOORClientData(_self));
} }

View File

@@ -63,6 +63,7 @@ PyObject* wxPyMake_##TYPE(TYPE* source, bool setThisOwn) { \
wxPyOORClientData* data = (wxPyOORClientData*)source->GetClientObject(); \ wxPyOORClientData* data = (wxPyOORClientData*)source->GetClientObject(); \
if (data) { \ if (data) { \
target = data->m_obj; \ target = data->m_obj; \
if (target) \
Py_INCREF(target); \ Py_INCREF(target); \
} \ } \
/* Otherwise make a new wrapper for it the old fashioned way and \ /* Otherwise make a new wrapper for it the old fashioned way and \
@@ -521,28 +522,30 @@ const wxRect wxGridNoCellRect;
%mutable; %mutable;
%rename(GRID_DEFAULT_NUMBER_ROWS) WXGRID_DEFAULT_NUMBER_ROWS; %{
%rename(GRID_DEFAULT_NUMBER_COLS) WXGRID_DEFAULT_NUMBER_COLS; #define wxGRID_DEFAULT_NUMBER_ROWS WXGRID_DEFAULT_NUMBER_ROWS
%rename(GRID_DEFAULT_ROW_HEIGHT) WXGRID_DEFAULT_ROW_HEIGHT; #define wxGRID_DEFAULT_NUMBER_COLS WXGRID_DEFAULT_NUMBER_COLS
%rename(GRID_DEFAULT_COL_WIDTH) WXGRID_DEFAULT_COL_WIDTH; #define wxGRID_DEFAULT_ROW_HEIGHT WXGRID_DEFAULT_ROW_HEIGHT
%rename(GRID_DEFAULT_COL_LABEL_HEIGHT) WXGRID_DEFAULT_COL_LABEL_HEIGHT; #define wxGRID_DEFAULT_COL_WIDTH WXGRID_DEFAULT_COL_WIDTH
%rename(GRID_DEFAULT_ROW_LABEL_WIDTH) WXGRID_DEFAULT_ROW_LABEL_WIDTH; #define wxGRID_DEFAULT_COL_LABEL_HEIGHT WXGRID_DEFAULT_COL_LABEL_HEIGHT
%rename(GRID_LABEL_EDGE_ZONE) WXGRID_LABEL_EDGE_ZONE; #define wxGRID_DEFAULT_ROW_LABEL_WIDTH WXGRID_DEFAULT_ROW_LABEL_WIDTH
%rename(GRID_MIN_ROW_HEIGHT) WXGRID_MIN_ROW_HEIGHT; #define wxGRID_LABEL_EDGE_ZONE WXGRID_LABEL_EDGE_ZONE
%rename(GRID_MIN_COL_WIDTH) WXGRID_MIN_COL_WIDTH; #define wxGRID_MIN_ROW_HEIGHT WXGRID_MIN_ROW_HEIGHT
%rename(GRID_DEFAULT_SCROLLBAR_WIDTH) WXGRID_DEFAULT_SCROLLBAR_WIDTH; #define wxGRID_MIN_COL_WIDTH WXGRID_MIN_COL_WIDTH
#define wxGRID_DEFAULT_SCROLLBAR_WIDTH WXGRID_DEFAULT_SCROLLBAR_WIDTH
%}
enum { enum {
WXGRID_DEFAULT_NUMBER_ROWS, wxGRID_DEFAULT_NUMBER_ROWS,
WXGRID_DEFAULT_NUMBER_COLS, wxGRID_DEFAULT_NUMBER_COLS,
WXGRID_DEFAULT_ROW_HEIGHT, wxGRID_DEFAULT_ROW_HEIGHT,
WXGRID_DEFAULT_COL_WIDTH, wxGRID_DEFAULT_COL_WIDTH,
WXGRID_DEFAULT_COL_LABEL_HEIGHT, wxGRID_DEFAULT_COL_LABEL_HEIGHT,
WXGRID_DEFAULT_ROW_LABEL_WIDTH, wxGRID_DEFAULT_ROW_LABEL_WIDTH,
WXGRID_LABEL_EDGE_ZONE, wxGRID_LABEL_EDGE_ZONE,
WXGRID_MIN_ROW_HEIGHT, wxGRID_MIN_ROW_HEIGHT,
WXGRID_MIN_COL_WIDTH, wxGRID_MIN_COL_WIDTH,
WXGRID_DEFAULT_SCROLLBAR_WIDTH wxGRID_DEFAULT_SCROLLBAR_WIDTH
}; };
@@ -556,6 +559,7 @@ class wxGridCellRenderer
public: public:
%extend { %extend {
void _setOORInfo(PyObject* _self) { void _setOORInfo(PyObject* _self) {
if (!self->GetClientObject())
self->SetClientObject(new wxPyOORClientData(_self)); self->SetClientObject(new wxPyOORClientData(_self));
} }
} }
@@ -762,6 +766,7 @@ class wxGridCellEditor
public: public:
%extend { %extend {
void _setOORInfo(PyObject* _self) { void _setOORInfo(PyObject* _self) {
if (!self->GetClientObject())
self->SetClientObject(new wxPyOORClientData(_self)); self->SetClientObject(new wxPyOORClientData(_self));
} }
} }
@@ -1030,6 +1035,7 @@ public:
%extend { %extend {
void _setOORInfo(PyObject* _self) { void _setOORInfo(PyObject* _self) {
if (!self->GetClientObject())
self->SetClientObject(new wxPyOORClientData(_self)); self->SetClientObject(new wxPyOORClientData(_self));
} }
} }
@@ -1095,6 +1101,7 @@ public:
%extend { %extend {
void _setOORInfo(PyObject* _self) { void _setOORInfo(PyObject* _self) {
if (!self->GetClientObject())
self->SetClientObject(new wxPyOORClientData(_self)); self->SetClientObject(new wxPyOORClientData(_self));
} }
} }
@@ -1156,6 +1163,7 @@ public:
%extend { %extend {
void _setOORInfo(PyObject* _self) { void _setOORInfo(PyObject* _self) {
if (!self->GetClientObject())
self->SetClientObject(new wxPyOORClientData(_self)); self->SetClientObject(new wxPyOORClientData(_self));
} }
} }