]> git.saurik.com Git - wxWidgets.git/commitdiff
prevent a reference leak when OOR objects are created
authorRobin Dunn <robin@alldunn.com>
Sat, 17 Jul 2004 17:52:29 +0000 (17:52 +0000)
committerRobin Dunn <robin@alldunn.com>
Sat, 17 Jul 2004 17:52:29 +0000 (17:52 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28281 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/contrib/ogl/_oglbasic.i
wxPython/src/_evthandler.i
wxPython/src/_grid_rename.i
wxPython/src/_sizers.i
wxPython/src/grid.i

index 7ceb86fac6474f8b8fb7e93cf82920b7b19cd167..70c18ca92f6f981a6b879822fa63965bbbf4f7c3 100644 (file)
@@ -89,7 +89,8 @@ public:
     void _setCallbackInfo(PyObject* self, PyObject* _class);
     %extend {
         void _setOORInfo(PyObject* _self) {
-            self->SetClientObject(new wxPyOORClientData(_self));
+            if (!self->GetClientObject())
+                self->SetClientObject(new wxPyOORClientData(_self));
         }
     }
     %pythoncode {
index 915d659f4d165751d3afcf1258c8f7c826c06bf0..164eb60d41a013355554e0d8c5548efb215175bc 100644 (file)
@@ -69,7 +69,8 @@ public:
     %extend {
         void _setOORInfo(PyObject* _self) {
             if (_self && _self != Py_None) {
-                self->SetClientObject(new wxPyOORClientData(_self));
+                if (!self->GetClientObject())
+                    self->SetClientObject(new wxPyOORClientData(_self));
             }
             else {
                 wxPyOORClientData* data = (wxPyOORClientData*)self->GetClientObject();
index b6e4bb35c251abb886a95f9b91c456f49675d425..befc12a39db5d09172db609f929e505b7006d0a5 100644 (file)
 %rename(GRID_VALUE_DATETIME)                wxGRID_VALUE_DATETIME;
 %rename(GridNoCellCoords)                   wxGridNoCellCoords;
 %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(PyGridCellRenderer)                 wxPyGridCellRenderer;
 %rename(GridCellStringRenderer)             wxGridCellStringRenderer;
index 6fe840b6ba096768be5f0274c3df8442d8b46dab..f015df3233e733110575f021a1959ac50b9091b2 100644 (file)
@@ -372,7 +372,8 @@ public:
 
     %extend {
         void _setOORInfo(PyObject* _self) {
-            self->SetClientObject(new wxPyOORClientData(_self));
+            if (!self->GetClientObject())
+                self->SetClientObject(new wxPyOORClientData(_self));
         }
 
         DocAStr(Add,
index 42544af69ce44c9818ad400874affad1a7b3154c..771190095b997263817203188b7d2c097ca65cac 100644 (file)
@@ -63,7 +63,8 @@ PyObject* wxPyMake_##TYPE(TYPE* source, bool setThisOwn) { \
         wxPyOORClientData* data = (wxPyOORClientData*)source->GetClientObject(); \
         if (data) { \
             target = data->m_obj; \
-            Py_INCREF(target); \
+            if (target) \
+                Py_INCREF(target); \
         } \
         /* Otherwise make a new wrapper for it the old fashioned way and \
            give it the OOR treatment */ \
@@ -521,28 +522,30 @@ const wxRect           wxGridNoCellRect;
 %mutable;
 
 
-%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;
+%{
+#define wxGRID_DEFAULT_NUMBER_ROWS        WXGRID_DEFAULT_NUMBER_ROWS
+#define wxGRID_DEFAULT_NUMBER_COLS        WXGRID_DEFAULT_NUMBER_COLS
+#define wxGRID_DEFAULT_ROW_HEIGHT         WXGRID_DEFAULT_ROW_HEIGHT
+#define wxGRID_DEFAULT_COL_WIDTH          WXGRID_DEFAULT_COL_WIDTH
+#define wxGRID_DEFAULT_COL_LABEL_HEIGHT   WXGRID_DEFAULT_COL_LABEL_HEIGHT
+#define wxGRID_DEFAULT_ROW_LABEL_WIDTH    WXGRID_DEFAULT_ROW_LABEL_WIDTH
+#define wxGRID_LABEL_EDGE_ZONE            WXGRID_LABEL_EDGE_ZONE
+#define wxGRID_MIN_ROW_HEIGHT             WXGRID_MIN_ROW_HEIGHT
+#define wxGRID_MIN_COL_WIDTH              WXGRID_MIN_COL_WIDTH
+#define wxGRID_DEFAULT_SCROLLBAR_WIDTH    WXGRID_DEFAULT_SCROLLBAR_WIDTH
+%}
 
 enum {
-    WXGRID_DEFAULT_NUMBER_ROWS,
-    WXGRID_DEFAULT_NUMBER_COLS,
-    WXGRID_DEFAULT_ROW_HEIGHT,
-    WXGRID_DEFAULT_COL_WIDTH,
-    WXGRID_DEFAULT_COL_LABEL_HEIGHT,
-    WXGRID_DEFAULT_ROW_LABEL_WIDTH,
-    WXGRID_LABEL_EDGE_ZONE,
-    WXGRID_MIN_ROW_HEIGHT,
-    WXGRID_MIN_COL_WIDTH,
-    WXGRID_DEFAULT_SCROLLBAR_WIDTH
+    wxGRID_DEFAULT_NUMBER_ROWS,
+    wxGRID_DEFAULT_NUMBER_COLS,
+    wxGRID_DEFAULT_ROW_HEIGHT,
+    wxGRID_DEFAULT_COL_WIDTH,
+    wxGRID_DEFAULT_COL_LABEL_HEIGHT,
+    wxGRID_DEFAULT_ROW_LABEL_WIDTH,
+    wxGRID_LABEL_EDGE_ZONE,
+    wxGRID_MIN_ROW_HEIGHT,
+    wxGRID_MIN_COL_WIDTH,
+    wxGRID_DEFAULT_SCROLLBAR_WIDTH
 };
 
 
@@ -556,7 +559,8 @@ class wxGridCellRenderer
 public:
     %extend {
         void _setOORInfo(PyObject* _self) {
-            self->SetClientObject(new wxPyOORClientData(_self));
+            if (!self->GetClientObject())
+                self->SetClientObject(new wxPyOORClientData(_self));
         }
     }
 
@@ -762,7 +766,8 @@ class  wxGridCellEditor
 public:
     %extend {
         void _setOORInfo(PyObject* _self) {
-            self->SetClientObject(new wxPyOORClientData(_self));
+            if (!self->GetClientObject())
+                self->SetClientObject(new wxPyOORClientData(_self));
         }
     }
 
@@ -1030,14 +1035,15 @@ public:
 
     %extend {
         void _setOORInfo(PyObject* _self) {
-            self->SetClientObject(new wxPyOORClientData(_self));
+            if (!self->GetClientObject())
+                self->SetClientObject(new wxPyOORClientData(_self));
         }
     }
 
     %pythonAppend wxGridCellAttr  "self._setOORInfo(self)"
 
     wxGridCellAttr(wxGridCellAttr *attrDefault = NULL);
-
+    
     wxGridCellAttr *Clone() const;
     void MergeWith(wxGridCellAttr *mergefrom);
     void IncRef();
@@ -1095,7 +1101,8 @@ public:
 
     %extend {
         void _setOORInfo(PyObject* _self) {
-            self->SetClientObject(new wxPyOORClientData(_self));
+            if (!self->GetClientObject())
+                self->SetClientObject(new wxPyOORClientData(_self));
         }
     }
 
@@ -1156,7 +1163,8 @@ public:
 
     %extend {
         void _setOORInfo(PyObject* _self) {
-            self->SetClientObject(new wxPyOORClientData(_self));
+            if (!self->GetClientObject())
+                self->SetClientObject(new wxPyOORClientData(_self));
         }
     }