]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/grid.i
Beginning of bitmap updates
[wxWidgets.git] / wxPython / src / grid.i
index 1fa8187e596aacb7dc40a7f42d274eaa564cbb94..5e0971123d82239465512a21ee0f8140aa07f9da 100644 (file)
 #define PYCALLBACK__GCAINTINT(PCLASS, CBNAME)                           \
     void CBNAME(wxGridCellAttr *attr, int a, int b) {                   \
         bool doSave = wxPyRestoreThread();                              \
-        if (m_myInst.findCallback(#CBNAME))                             \
-            m_myInst.callCallback(                                      \
-                Py_BuildValue("(Oii)",                                  \
-                              wxPyConstructObject((void*)attr, "wxGridCellAttr"),    \
-                              a, b));                                   \
+        if (m_myInst.findCallback(#CBNAME)) {                           \
+            PyObject* obj = wxPyConstructObject((void*)attr, "wxGridCellAttr");\
+            m_myInst.callCallback(Py_BuildValue("(Oii)", obj, a, b));   \
+            Py_DECREF(obj);                                             \
+        }                                                               \
         else                                                            \
             PCLASS::CBNAME(attr, a, b);                                 \
         wxPySaveThread(doSave);                                         \
 #define PYCALLBACK__GCAINT(PCLASS, CBNAME)                              \
     void CBNAME(wxGridCellAttr *attr, int val) {                        \
         bool doSave = wxPyRestoreThread();                              \
-        if (m_myInst.findCallback(#CBNAME))                             \
-            m_myInst.callCallback(                                      \
-                Py_BuildValue("(Oi)",                                   \
-                              wxPyConstructObject((void*)attr, "wxGridCellAttr"),    \
-                              val));                                    \
+        if (m_myInst.findCallback(#CBNAME)) {                           \
+            PyObject* obj = wxPyConstructObject((void*)attr, "wxGridCellAttr");\
+            m_myInst.callCallback(Py_BuildValue("(Oi)", obj, val));     \
+            Py_DECREF(obj);                                             \
+        }                                                               \
         else                                                            \
             PCLASS::CBNAME(attr, val);                                  \
         wxPySaveThread(doSave);                                         \
             PyObject* ro;                                               \
             ro = m_myInst.callCallbackObj(Py_BuildValue("(ii)",a,b));   \
             if (ro) {                                                   \
-                rval = PyString_AsString(PyObject_Str(ro));             \
-                Py_DECREF(ro);                                          \
+                PyObject* str = PyObject_Str(ro);                       \
+                rval = PyString_AsString(str);                          \
+                Py_DECREF(ro);  Py_DECREF(str);                         \
             }                                                           \
         }                                                               \
         wxPySaveThread(doSave);                                         \
             PyObject* ro;                                               \
             ro = m_myInst.callCallbackObj(Py_BuildValue("(ii)",a,b));   \
             if (ro) {                                                   \
-                rval = PyString_AsString(PyObject_Str(ro));             \
-                Py_DECREF(ro);                                          \
+                PyObject* str = PyObject_Str(ro);                       \
+                rval = PyString_AsString(str);                          \
+                Py_DECREF(ro);  Py_DECREF(str);                         \
             }                                                           \
         } else                                                          \
             rval = PCLASS::CBNAME(a, b);                                \
             PyObject* ro;                                               \
             ro = m_myInst.callCallbackObj(Py_BuildValue("(ii)",a,b));   \
             if (ro) {                                                   \
-                rval = PyFloat_AsDouble(PyObject_Str(ro));              \
-                Py_DECREF(ro);                                          \
+                PyObject* str = PyObject_Str(ro);                       \
+                rval = PyFloat_AsDouble(str);                           \
+                Py_DECREF(ro);   Py_DECREF(str);                        \
             }                                                           \
         } else                                                          \
             rval = PCLASS::CBNAME(a, b);                                \
             PyObject* ro;                                               \
             ro = m_myInst.callCallbackObj(Py_BuildValue("(i)",a));      \
             if (ro) {                                                   \
-                rval = PyString_AsString(PyObject_Str(ro));             \
-                Py_DECREF(ro);                                          \
+                PyObject* str = PyObject_Str(ro);                       \
+                rval = PyString_AsString(str);                          \
+                Py_DECREF(ro);   Py_DECREF(str);                        \
             }                                                           \
         } else                                                          \
             rval = PCLASS::CBNAME(a);                                   \
@@ -982,7 +986,6 @@ public:
     PYCALLBACK__GCAINT(wxGridTableBase, SetColAttr);
 
 
-
     wxString GetValue(int row, int col) {
         bool doSave = wxPyRestoreThread();
         wxString rval;
@@ -990,8 +993,10 @@ public:
             PyObject* ro;
             ro = m_myInst.callCallbackObj(Py_BuildValue("(ii)",row,col));
             if (ro) {
-                rval = PyString_AsString(PyObject_Str(ro));
+                PyObject* str = PyObject_Str(ro);
+                rval = PyString_AsString(str);
                 Py_DECREF(ro);
+                Py_DECREF(str);
             }
         }
         wxPySaveThread(doSave);