Fixed a bunch of leaking references in how the callbacks deal with

objects.  Should be MUCH better now.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8887 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2000-12-10 08:37:52 +00:00
parent 2d5e89e1cd
commit de20db997d
32 changed files with 408 additions and 184 deletions

View File

@ -31,6 +31,8 @@ object, (usually a window.)
Added wxNotifyEvent.Allow()
Fixed GOBS of reference leaks.
New in 2.2.2

View File

@ -40,9 +40,14 @@ elseiff "%1" == "f" then
shift
set CMD=%SETUP% %FLAGS% FINAL=1 build_ext --inplace %1 %2 %3 %4 %5 %6 %7 %8 %9
rem "h" --> HYBRID
elseiff "%1" == "h" then
shift
set CMD=%SETUP% %FLAGS% HYBRID=1 build_ext --inplace %1 %2 %3 %4 %5 %6 %7 %8 %9
rem (no command arg) --> normal build for development
else
set CMD=%SETUP% %FLAGS% HYBRID=1 build_ext --inplace %1 %2 %3 %4 %5 %6 %7 %8 %9
set CMD=%SETUP% %FLAGS% HYBRID=0 build_ext --inplace --debug %1 %2 %3 %4 %5 %6 %7 %8 %9
endiff

View File

@ -855,6 +855,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxBusyInfo","_class_wxBusyInfo",0},
{ "_class_wxMenuEvent","_wxMenuEvent",0},
{ "_wxPaletteChangedEvent","_class_wxPaletteChangedEvent",0},
{ "_wxJoystick","_class_wxJoystick",0},
{ "_class_wxPyBitmapDataObject","_wxPyBitmapDataObject",0},
{ "_wxClientDC","_class_wxClientDC",0},
{ "_wxMouseEvent","_class_wxMouseEvent",0},
@ -1037,6 +1038,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxGauge","_class_wxGauge",0},
{ "_class_wxCheckListBox","_wxCheckListBox",0},
{ "_class_wxBusyInfo","_wxBusyInfo",0},
{ "_class_wxJoystick","_wxJoystick",0},
{ "_class_wxCommandEvent","_wxCommandEvent",0},
{ "_class_wxClientDC","_wxClientDC",0},
{ "_class_wxSizeEvent","_wxSizeEvent",0},

View File

@ -473,6 +473,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxBusyInfo","_class_wxBusyInfo",0},
{ "_class_wxMenuEvent","_wxMenuEvent",0},
{ "_wxPaletteChangedEvent","_class_wxPaletteChangedEvent",0},
{ "_wxJoystick","_class_wxJoystick",0},
{ "_class_wxPyBitmapDataObject","_wxPyBitmapDataObject",0},
{ "_class_wxPyCircleShape","_wxPyCircleShape",0},
{ "_wxClientDC","_class_wxClientDC",0},
@ -661,6 +662,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxGauge","_class_wxGauge",0},
{ "_class_wxCheckListBox","_wxCheckListBox",0},
{ "_class_wxBusyInfo","_wxBusyInfo",0},
{ "_class_wxJoystick","_wxJoystick",0},
{ "_class_wxCommandEvent","_wxCommandEvent",0},
{ "_class_wxClientDC","_wxClientDC",0},
{ "_class_wxSizeEvent","_wxSizeEvent",0},

View File

@ -8658,6 +8658,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxBusyInfo","_class_wxBusyInfo",0},
{ "_class_wxMenuEvent","_wxMenuEvent",0},
{ "_wxPaletteChangedEvent","_class_wxPaletteChangedEvent",0},
{ "_wxJoystick","_class_wxJoystick",0},
{ "_class_wxPyBitmapDataObject","_wxPyBitmapDataObject",0},
{ "_wxClientDC","_class_wxClientDC",0},
{ "_wxMouseEvent","_class_wxMouseEvent",0},
@ -8838,6 +8839,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxGauge","_class_wxGauge",0},
{ "_class_wxCheckListBox","_wxCheckListBox",0},
{ "_class_wxBusyInfo","_wxBusyInfo",0},
{ "_class_wxJoystick","_wxJoystick",0},
{ "_class_wxCommandEvent","_wxCommandEvent",0},
{ "_class_wxClientDC","_wxClientDC",0},
{ "_class_wxSizeEvent","_wxSizeEvent",0},

View File

@ -2305,6 +2305,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxBusyInfo","_class_wxBusyInfo",0},
{ "_class_wxMenuEvent","_wxMenuEvent",0},
{ "_wxPaletteChangedEvent","_class_wxPaletteChangedEvent",0},
{ "_wxJoystick","_class_wxJoystick",0},
{ "_class_wxPyBitmapDataObject","_wxPyBitmapDataObject",0},
{ "_wxClientDC","_class_wxClientDC",0},
{ "_wxMouseEvent","_class_wxMouseEvent",0},
@ -2488,6 +2489,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxGauge","_class_wxGauge",0},
{ "_class_wxCheckListBox","_wxCheckListBox",0},
{ "_class_wxBusyInfo","_wxBusyInfo",0},
{ "_class_wxJoystick","_wxJoystick",0},
{ "_class_wxCommandEvent","_wxCommandEvent",0},
{ "_class_wxClientDC","_wxClientDC",0},
{ "_class_wxSizeEvent","_wxSizeEvent",0},

View File

@ -12875,6 +12875,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxBusyInfo","_class_wxBusyInfo",0},
{ "_class_wxMenuEvent","_wxMenuEvent",0},
{ "_wxPaletteChangedEvent","_class_wxPaletteChangedEvent",0},
{ "_wxJoystick","_class_wxJoystick",0},
{ "_class_wxPyBitmapDataObject","_wxPyBitmapDataObject",0},
{ "_wxClientDC","_class_wxClientDC",0},
{ "_wxMouseEvent","_class_wxMouseEvent",0},
@ -13087,6 +13088,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxGauge","_class_wxGauge",0},
{ "_class_wxCheckListBox","_wxCheckListBox",0},
{ "_class_wxBusyInfo","_wxBusyInfo",0},
{ "_class_wxJoystick","_wxJoystick",0},
{ "_class_wxCommandEvent","_wxCommandEvent",0},
{ "_class_wxClientDC","_wxClientDC",0},
{ "_class_wxSizeEvent","_wxSizeEvent",0},

View File

@ -8215,6 +8215,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxBusyInfo","_class_wxBusyInfo",0},
{ "_class_wxMenuEvent","_wxMenuEvent",0},
{ "_wxPaletteChangedEvent","_class_wxPaletteChangedEvent",0},
{ "_wxJoystick","_class_wxJoystick",0},
{ "_class_wxPyBitmapDataObject","_wxPyBitmapDataObject",0},
{ "_class_wxPyCircleShape","_wxPyCircleShape",0},
{ "_wxClientDC","_class_wxClientDC",0},
@ -8422,6 +8423,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxGauge","_class_wxGauge",0},
{ "_class_wxCheckListBox","_wxCheckListBox",0},
{ "_class_wxBusyInfo","_wxBusyInfo",0},
{ "_class_wxJoystick","_wxJoystick",0},
{ "_class_wxCommandEvent","_wxCommandEvent",0},
{ "_class_wxClientDC","_wxClientDC",0},
{ "_class_wxSizeEvent","_wxSizeEvent",0},

View File

@ -8823,6 +8823,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxBusyInfo","_class_wxBusyInfo",0},
{ "_class_wxMenuEvent","_wxMenuEvent",0},
{ "_wxPaletteChangedEvent","_class_wxPaletteChangedEvent",0},
{ "_wxJoystick","_class_wxJoystick",0},
{ "_class_wxPyBitmapDataObject","_wxPyBitmapDataObject",0},
{ "_wxClientDC","_class_wxClientDC",0},
{ "_wxMouseEvent","_class_wxMouseEvent",0},
@ -9006,6 +9007,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxGauge","_class_wxGauge",0},
{ "_class_wxCheckListBox","_wxCheckListBox",0},
{ "_class_wxBusyInfo","_wxBusyInfo",0},
{ "_class_wxJoystick","_wxJoystick",0},
{ "_class_wxCommandEvent","_class_wxStyledTextEvent",SwigwxStyledTextEventTowxCommandEvent},
{ "_class_wxCommandEvent","_wxStyledTextEvent",SwigwxStyledTextEventTowxCommandEvent},
{ "_class_wxCommandEvent","_wxCommandEvent",0},

View File

@ -19,7 +19,7 @@ class MyParentFrame(wxMDIParentFrame):
menubar.Append(menu, "&File")
self.SetMenuBar(menubar)
#self.CreateStatusBar()
self.CreateStatusBar()
EVT_MENU(self, 5000, self.OnNewWindow)
EVT_MENU(self, 5001, self.OnExit)

View File

@ -0,0 +1,140 @@
#!/usr/bin/env python
from wxPython.wx import *
from wxScrolledWindow import MyCanvas
#----------------------------------------------------------------------
class MyParentFrame(wxMDIParentFrame):
ID_WINDOW_TOP = 5100
ID_WINDOW_LEFT1 = 5101
ID_WINDOW_LEFT2 = 5102
ID_WINDOW_BOTTOM = 5103
def __init__(self):
wxMDIParentFrame.__init__(self, None, -1, "MDI Parent", size=(600,400),
style = wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL)
self.winCount = 0
menu = wxMenu()
menu.Append(5000, "&New Window")
menu.AppendSeparator()
menu.Append(5001, "E&xit")
menubar = wxMenuBar()
menubar.Append(menu, "&File")
self.SetMenuBar(menubar)
#self.CreateStatusBar()
EVT_MENU(self, 5000, self.OnNewWindow)
EVT_MENU(self, 5001, self.OnExit)
EVT_SASH_DRAGGED_RANGE(self,
self.ID_WINDOW_TOP, self.ID_WINDOW_BOTTOM,
self.OnSashDrag)
EVT_SIZE(self, self.OnSize)
# Create some layout windows
# A window like a toolbar
win = wxSashLayoutWindow(self, self.ID_WINDOW_TOP, style = wxNO_BORDER|wxSW_3D)
win.SetDefaultSize((1000, 30))
win.SetOrientation(wxLAYOUT_HORIZONTAL)
win.SetAlignment(wxLAYOUT_TOP)
win.SetBackgroundColour(wxColour(255, 0, 0))
win.SetSashVisible(wxSASH_BOTTOM, true)
self.topWindow = win
# A window like a statusbar
win = wxSashLayoutWindow(self, self.ID_WINDOW_BOTTOM, style = wxNO_BORDER|wxSW_3D)
win.SetDefaultSize((1000, 30))
win.SetOrientation(wxLAYOUT_HORIZONTAL)
win.SetAlignment(wxLAYOUT_BOTTOM)
win.SetBackgroundColour(wxColour(0, 0, 255))
win.SetSashVisible(wxSASH_TOP, true)
self.bottomWindow = win
# A window to the left of the client window
win = wxSashLayoutWindow(self, self.ID_WINDOW_LEFT1, style = wxNO_BORDER|wxSW_3D)
win.SetDefaultSize((120, 1000))
win.SetOrientation(wxLAYOUT_VERTICAL)
win.SetAlignment(wxLAYOUT_LEFT)
win.SetBackgroundColour(wxColour(0, 255, 0))
win.SetSashVisible(wxSASH_RIGHT, TRUE)
win.SetExtraBorderSize(10)
textWindow = wxTextCtrl(win, -1, "", wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE|wxSUNKEN_BORDER)
textWindow.SetValue("A sub window")
self.leftWindow1 = win
# Another window to the left of the client window
win = wxSashLayoutWindow(self, self.ID_WINDOW_LEFT2, style = wxNO_BORDER|wxSW_3D)
win.SetDefaultSize((120, 1000))
win.SetOrientation(wxLAYOUT_VERTICAL)
win.SetAlignment(wxLAYOUT_LEFT)
win.SetBackgroundColour(wxColour(0, 255, 255))
win.SetSashVisible(wxSASH_RIGHT, TRUE)
self.leftWindow2 = win
def OnSashDrag(self, event):
if event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE:
return
eID = event.GetId()
if eID == self.ID_WINDOW_TOP:
self.topWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height))
elif eID == self.ID_WINDOW_LEFT1:
self.leftWindow1.SetDefaultSize(wxSize(event.GetDragRect().width, 1000))
elif eID == self.ID_WINDOW_LEFT2:
self.leftWindow2.SetDefaultSize(wxSize(event.GetDragRect().width, 1000))
elif eID == self.ID_WINDOW_BOTTOM:
self.bottomWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height))
wxLayoutAlgorithm().LayoutMDIFrame(self)
self.GetClientWindow().Refresh()
def OnSize(self, event):
wxLayoutAlgorithm().LayoutMDIFrame(self)
def OnExit(self, evt):
self.Close(true)
def OnNewWindow(self, evt):
self.winCount = self.winCount + 1
win = wxMDIChildFrame(self, -1, "Child Window: %d" % self.winCount)
canvas = MyCanvas(win)
win.Show(true)
#----------------------------------------------------------------------
class MyApp(wxApp):
def OnInit(self):
frame = MyParentFrame()
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()

View File

@ -15,6 +15,9 @@ class TestSashWindow(wxPanel):
self.log = log
# will accupy the space not uised by the Layout Algorithm
self.remainingSpace = wxPanel(self, -1, style=wxSUNKEN_BORDER)
EVT_SASH_DRAGGED_RANGE(self, self.ID_WINDOW_TOP,
self.ID_WINDOW_BOTTOM, self.OnSashDrag)
EVT_SIZE(self, self.OnSize)
@ -56,10 +59,9 @@ class TestSashWindow(wxPanel):
win.SetBackgroundColour(wxColour(0, 255, 0))
win.SetSashVisible(wxSASH_RIGHT, TRUE)
win.SetExtraBorderSize(10)
textWindow = wxTextCtrl(win, -1, "", wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE|wxSUNKEN_BORDER)
textWindow.SetValue("A help window")
textWindow.SetValue("A sub window")
self.leftWindow1 = win
@ -95,11 +97,11 @@ class TestSashWindow(wxPanel):
elif eID == self.ID_WINDOW_BOTTOM:
self.bottomWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height))
wxLayoutAlgorithm().LayoutWindow(self)
wxLayoutAlgorithm().LayoutWindow(self, self.remainingSpace)
self.remainingSpace.Refresh()
def OnSize(self, event):
wxLayoutAlgorithm().LayoutWindow(self)
wxLayoutAlgorithm().LayoutWindow(self, self.remainingSpace)
#---------------------------------------------------------------------------
@ -125,29 +127,4 @@ def runTest(frame, nb, log):
overview = """\
wxSashLayoutWindow responds to OnCalculateLayout events generated by wxLayoutAlgorithm. It allows the application to use simple accessors to specify how the window should be laid out, rather than having to respond to events. The fact that the class derives from wxSashWindow allows sashes to be used if required, to allow the windows to be user-resizable.
wxSashLayoutWindow()
-------------------------------------------
Default constructor.
wxSashLayoutWindow(wxSashLayoutWindow* parent, wxSashLayoutWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCLIP_CHILDREN | wxSW_3D, const wxString& name = "layoutWindow")
Constructs a sash layout window, which can be a child of a frame, dialog or any other non-control window.
Parameters
-------------------
parent = Pointer to a parent window.
id = Window identifier. If -1, will automatically create an identifier.
pos = Window position. wxDefaultPosition is (-1, -1) which indicates that wxSashLayoutWindows should generate a default position for the window. If using the wxSashLayoutWindow class directly, supply an actual position.
size = Window size. wxDefaultSize is (-1, -1) which indicates that wxSashLayoutWindows should generate a default size for the window.
style = Window style. For window styles, please see wxSashLayoutWindow.
name = Window name.
"""

View File

@ -78,7 +78,7 @@ class TestToolBar(wxFrame):
event.Skip()
def OnClearSB(self, event):
def OnClearSB(self, event): # called for the timer event handler
self.SetStatusText("")
self.timer.Stop()
self.timer = None

View File

@ -13,7 +13,7 @@ from my_distutils import run_swig, contrib_copy_tree
# flags and values that affect this script
#----------------------------------------------------------------------
VERSION = "2.3.0b1"
VERSION = "2.3b1"
DESCRIPTION = "Cross platform GUI toolkit for Python"
AUTHOR = "Robin Dunn"
AUTHOR_EMAIL = "robin@alldunn.com"
@ -199,7 +199,7 @@ if IN_CVS_TREE and newer('setup.py', 'src/__version__.py'):
print 'Preparing CORE...'
swig_force = force
swig_args = ['-c++', '-shadow', '-python', '-keyword', '-dascii',
swig_args = ['-c++', '-shadow', '-python', '-keyword', '-dnone', #'-dascii',
'-I./src', '-D'+WXPLAT]
swig_deps = ['src/my_typemaps.i']

View File

@ -1 +1 @@
ver = '2.3.0b1'
ver = '2.3b1'

View File

@ -75,7 +75,9 @@
// Py_DECREF(arg);
// // set ThisOwn
// PyObject_SetAttrString($target, "thisown", PyInt_FromLong(1));
// PyObject* one = PyInt_FromLong(1);
// PyObject_SetAttrString($target, "thisown", one);
// Py_DECREF(one);
// }
// } else {
// Py_INCREF(Py_None);

View File

@ -339,6 +339,7 @@ public:
};
%new wxColour* wxNamedColour(const wxString& colorName);
%{ // Alternate 'constructor'
wxColour* wxNamedColour(const wxString& colorName) {
return new wxColour(colorName);

View File

@ -71,11 +71,11 @@
#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); \
@ -89,11 +89,11 @@
#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); \
@ -136,8 +136,9 @@
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); \
@ -163,8 +164,9 @@
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); \
@ -237,8 +239,9 @@
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); \
@ -309,8 +312,9 @@
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);

View File

@ -105,6 +105,11 @@ int wxPyApp::MainLoop(void) {
//---------------------------------------------------------------------
//----------------------------------------------------------------------
#ifdef __WXMSW__
#include "wx/msw/msvcrt.h"
#endif
int WXDLLEXPORT wxEntryStart( int argc, char** argv );
int WXDLLEXPORT wxEntryInitGui();
void WXDLLEXPORT wxEntryCleanup();
@ -121,6 +126,11 @@ static char* __nullArgv[1] = { 0 };
// wxcmodule is imported. (Before there is a wxApp object.)
void __wxPreStart()
{
#ifdef __WXMSW__
// wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
#endif
#ifdef WXP_WITH_THREAD
PyEval_InitThreads();
wxPyEventThreadState = PyThreadState_Get();
@ -158,11 +168,12 @@ PyObject* __wxStart(PyObject* /* self */, PyObject* args)
if (!PyArg_ParseTuple(args, "O", &onInitFunc))
return NULL;
#if 0 // Try it out without this check, soo how it does...
if (wxTopLevelWindows.Number() > 0) {
PyErr_SetString(PyExc_TypeError, "Only 1 wxApp per process!");
return NULL;
}
#endif
// This is the next part of the wxEntry functionality...
PyObject* sysargv = PySys_GetObject("argv");
@ -280,7 +291,9 @@ PyObject* wxPyConstructObject(void* ptr,
Py_DECREF(arg);
if (setThisOwn) {
PyObject_SetAttrString(obj, "thisown", PyInt_FromLong(1));
PyObject* one = PyInt_FromLong(1);
PyObject_SetAttrString(obj, "thisown", one);
Py_DECREF(one);
}
return obj;
@ -427,12 +440,12 @@ void wxPyCallbackHelper::setSelf(PyObject* self, PyObject* klass, int incref) {
// If the object (m_self) has an attibute of the given name, and if that
// attribute is a method, and if that method's class is not from a base class,
// then we'll save a pointer to the method so callCallback can call it.
bool wxPyCallbackHelper::findCallback(const wxString& name) const {
bool wxPyCallbackHelper::findCallback(const char* name) const {
wxPyCallbackHelper* self = (wxPyCallbackHelper*)this; // cast away const
self->m_lastFound = NULL;
if (m_self && PyObject_HasAttrString(m_self, (char*)name.c_str())) {
if (m_self && PyObject_HasAttrString(m_self, (char*)name)) {
PyObject* method;
method = PyObject_GetAttrString(m_self, (char*)name.c_str());
method = PyObject_GetAttrString(m_self, (char*)name);
if (PyMethod_Check(method) &&
((PyMethod_GET_CLASS(method) == m_class) ||
@ -440,6 +453,9 @@ bool wxPyCallbackHelper::findCallback(const wxString& name) const {
self->m_lastFound = method;
}
else {
Py_DECREF(method);
}
}
return m_lastFound != NULL;
}
@ -461,10 +477,17 @@ int wxPyCallbackHelper::callCallback(PyObject* argTuple) const {
// Invoke the Python callable object, returning the raw PyObject return
// value. Caller should DECREF the return value and also call PyEval_SaveThread.
PyObject* wxPyCallbackHelper::callCallbackObj(PyObject* argTuple) const {
PyObject* result;
wxPyCallbackHelper* self = (wxPyCallbackHelper*)this; // cast away const
PyObject* result;
result = PyEval_CallObject(m_lastFound, argTuple);
// Save a copy of the pointer in case the callback generates another
// callback. In that case m_lastFound will have a different value when
// it gets back here...
PyObject* method = m_lastFound;
result = PyEval_CallObject(method, argTuple);
Py_DECREF(argTuple);
Py_DECREF(method);
if (!result) {
PyErr_Print();
}
@ -987,7 +1010,7 @@ bool wxColour_helper(PyObject* source, wxColour** obj) {
}
error:
PyErr_SetString(PyExc_TypeError, "Expected a wxColour object or a string containing a colour name or #RRGGBB.");
PyErr_SetString(PyExc_TypeError, "Expected a wxColour object or a string containing a colour name or '#RRGGBB'.");
return FALSE;
}
@ -998,3 +1021,4 @@ bool wxColour_helper(PyObject* source, wxColour** obj) {

View File

@ -15,7 +15,6 @@
#include <wx/wx.h>
//----------------------------------------------------------------------
// if we want to handle threads and Python threads are available...
@ -216,7 +215,7 @@ public:
void setSelf(PyObject* self, PyObject* klass, int incref=TRUE);
bool findCallback(const wxString& name) const;
bool findCallback(const char* name) const;
int callCallback(PyObject* argTuple) const;
PyObject* callCallbackObj(PyObject* argTuple) const;
@ -393,9 +392,11 @@ public:
#define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(wxDC& a) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(O)", \
wxPyConstructObject(&a, "wxDC"))); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(&a, "wxDC"); \
m_myInst.callCallback(Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
@ -416,9 +417,11 @@ public:
#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(wxDC& a, bool b) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(Oi)", \
wxPyConstructObject(&a, "wxDC"), (int)b)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(&a, "wxDC"); \
m_myInst.callCallback(Py_BuildValue("(Oi)", obj, (int)b)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a, b); \
wxPySaveThread(doSave); \
@ -437,9 +440,11 @@ public:
#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(wxDC& a, bool b) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(Oi)", \
wxPyConstructObject(&a, "wxDC"), (int)b)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(&a, "wxDC"); \
m_myInst.callCallback(Py_BuildValue("(Oi)", obj, (int)b)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a, b); \
wxPySaveThread(doSave); \
@ -499,10 +504,11 @@ public:
#define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
wxPyConstructObject(&a, "wxDC"), \
b, c, d, e, (int)f)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(&a, "wxDC"); \
m_myInst.callCallback(Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a, b, c, d, e, f); \
wxPySaveThread(doSave); \
@ -522,10 +528,11 @@ public:
bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
bool doSave = wxPyRestoreThread(); \
bool rval; \
if (m_myInst.findCallback(#CBNAME)) \
rval = m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
wxPyConstructObject(&a, "wxDC"), \
b, c, d, e, (int)f)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(&a, "wxDC"); \
rval = m_myInst.callCallback(Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
Py_DECREF(obj); \
} \
else \
rval = PCLASS::CBNAME(a, b, c, d, e, f); \
wxPySaveThread(doSave); \
@ -566,10 +573,11 @@ public:
#define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(Odddd)", \
wxPyConstructObject(&a, "wxDC"), \
b, c, d, e)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(&a, "wxDC"); \
m_myInst.callCallback(Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a, b, c, d, e); \
wxPySaveThread(doSave); \
@ -588,10 +596,11 @@ public:
#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(wxDC& a, bool b) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(Oi)", \
wxPyConstructObject(&a, "wxDC"), \
(int)b)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(&a, "wxDC"); \
m_myInst.callCallback(Py_BuildValue("(Oi)", obj, (int)b)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a, b); \
wxPySaveThread(doSave); \
@ -611,10 +620,11 @@ public:
void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
int e, int f) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(Oiddii)", \
wxPyConstructObject(a, "wxPyControlPoint"), \
(int)b, c, d, e, f)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(a, "wxPyControlPoint"); \
m_myInst.callCallback(Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a, b, c, d, e, f); \
wxPySaveThread(doSave); \
@ -634,10 +644,11 @@ public:
#define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(Oddii)", \
wxPyConstructObject(a, "wxPyControlPoint"), \
b, c, d, e)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(a, "wxPyControlPoint"); \
m_myInst.callCallback(Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a, b, c, d, e); \
wxPySaveThread(doSave); \
@ -758,8 +769,9 @@ public:
PyObject* ro; \
ro = m_myInst.callCallbackObj(Py_BuildValue("(s)", a.c_str())); \
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); \
@ -779,8 +791,9 @@ public:
PyObject* ro; \
ro = m_myInst.callCallbackObj(Py_BuildValue("(si)", a.c_str(),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); \
@ -825,8 +838,9 @@ public:
PyObject* ro; \
ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
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 \
@ -852,8 +866,9 @@ public:
PyObject* ro; \
ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
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); \
@ -870,9 +885,11 @@ public:
bool CLASS::CBNAME(const wxHtmlTag& a) { \
bool rval = FALSE; \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
rval = m_myInst.callCallback(Py_BuildValue("(O)", \
wxPyConstructObject((void*)&a,"wxHtmlTag"))); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject((void*)&a,"wxHtmlTag"); \
rval = m_myInst.callCallback(Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
wxPySaveThread(doSave); \
return rval; \
}
@ -926,9 +943,11 @@ public:
bool CLASS::CBNAME(wxWindow* a) { \
bool rval; \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
rval = m_myInst.callCallback(Py_BuildValue("(O)", \
wxPyConstructObject((void*)a,"wxWindow"))); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject((void*)a,"wxWindow"); \
rval = m_myInst.callCallback(Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
else \
rval = PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
@ -993,13 +1012,15 @@ public:
wxFSFile* rval=0; \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* ro; \
ro=m_myInst.callCallbackObj(Py_BuildValue("(Os)", \
wxPyConstructObject(&a, "(wxFileSystemC"),b.c_str())); \
PyObject* obj = wxPyConstructObject(&a, "(wxFileSystem"); \
ro = m_myInst.callCallbackObj(Py_BuildValue("(Os)", \
obj, b.c_str())); \
if (ro) { \
SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
Py_DECREF(ro); \
} \
} \
Py_DECREF(obj); \
} \
wxPySaveThread(doSave); \
return rval; \
};
@ -1117,18 +1138,20 @@ public:
void base_##CBNAME(const Type& a);
#define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
void CLASS::CBNAME(const Type& a) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(O)", \
wxPyConstructObject((void*)&a, #Type))); \
else \
PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
} \
void CLASS::base_##CBNAME(const Type& a) { \
PCLASS::CBNAME(a); \
#define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
void CLASS::CBNAME(const Type& a) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject((void*)&a, #Type); \
m_myInst.callCallback(Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
} \
void CLASS::base_##CBNAME(const Type& a) { \
PCLASS::CBNAME(a); \
}
@ -1139,18 +1162,20 @@ public:
void base_##CBNAME(Type& a);
#define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
void CLASS::CBNAME(Type& a) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(O)", \
wxPyConstructObject(&a, #Type))); \
else \
PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
} \
void CLASS::base_##CBNAME(Type& a) { \
PCLASS::CBNAME(a); \
#define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
void CLASS::CBNAME(Type& a) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject((void*)&a, #Type); \
m_myInst.callCallback(Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
} \
void CLASS::base_##CBNAME(Type& a) { \
PCLASS::CBNAME(a); \
}
//---------------------------------------------------------------------------
@ -1160,20 +1185,22 @@ public:
bool base_##CBNAME(Type& a);
#define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
bool CLASS::CBNAME(Type& a) { \
bool rv; \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
rv = m_myInst.callCallback(Py_BuildValue("(O)", \
wxPyConstructObject(&a, #Type))); \
else \
rv = PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
return rv; \
} \
bool CLASS::base_##CBNAME(Type& a) { \
return PCLASS::CBNAME(a); \
#define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
bool CLASS::CBNAME(Type& a) { \
bool rv; \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject((void*)&a, #Type); \
rv = m_myInst.callCallback(Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
else \
rv = PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
return rv; \
} \
bool CLASS::base_##CBNAME(Type& a) { \
return PCLASS::CBNAME(a); \
}
//---------------------------------------------------------------------------

View File

@ -275,12 +275,14 @@ public:
}
void OnExit() {
bool doSave = wxPyRestoreThread();
Py_DECREF(m_tagHandlerClass);
m_tagHandlerClass = NULL;
for (size_t x=0; x < m_objArray.GetCount(); x++) {
PyObject* obj = (PyObject*)m_objArray.Item(x);
Py_DECREF(obj);
}
wxPySaveThread(doSave);
};
void FillHandlersTable(wxHtmlWinParser *parser) {
@ -434,6 +436,7 @@ IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
if (m_myInst.findCallback("OnLinkClicked")) {
PyObject* obj = wxPyConstructObject((void*)&link, "wxHtmlLinkInfo");
m_myInst.callCallback(Py_BuildValue("(O)", obj));
Py_DECREF(obj);
}
else
wxHtmlWindow::OnLinkClicked(link);

View File

@ -255,7 +255,9 @@ public:
bool doSave = wxPyRestoreThread();
wxRect* newRect = new wxRect(dest);
obj = wxPyConstructObject((void*)newRect, "wxRect");
PyObject_SetAttrString(obj, "thisown", PyInt_FromLong(1));
PyObject* one = PyInt_FromLong(1);
PyObject_SetAttrString(obj, "thisown", one);
Py_DECREF(one);
wxPySaveThread(doSave);
return obj;
}

View File

@ -1 +1 @@
*.doc

View File

@ -488,7 +488,9 @@ static PyObject *_wrap_wxFSFile_GetStream(PyObject *self, PyObject *args, PyObje
Py_DECREF(arg);
// set ThisOwn
PyObject_SetAttrString(_resultobj, "thisown", PyInt_FromLong(1));
PyObject* one = PyInt_FromLong(1);
PyObject_SetAttrString(_resultobj, "thisown", one);
Py_DECREF(one);
}
} else {
Py_INCREF(Py_None);

View File

@ -134,11 +134,11 @@ static char* wxStringErrorMsg = "string type is required for parameter";
#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); \
@ -152,11 +152,11 @@ static char* wxStringErrorMsg = "string type is required for parameter";
#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); \
@ -199,8 +199,9 @@ static char* wxStringErrorMsg = "string type is required for parameter";
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); \
@ -226,8 +227,9 @@ static char* wxStringErrorMsg = "string type is required for parameter";
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); \
@ -300,8 +302,9 @@ static char* wxStringErrorMsg = "string type is required for parameter";
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); \
@ -372,8 +375,9 @@ static char* wxStringErrorMsg = "string type is required for parameter";
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); \
@ -710,7 +714,6 @@ public:
PYCALLBACK__GCAINT(wxGridTableBase, SetColAttr);
wxString GetValue(int row, int col) {
bool doSave = wxPyRestoreThread();
wxString rval;
@ -718,8 +721,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);

View File

@ -163,12 +163,14 @@ public:
}
void OnExit() {
bool doSave = wxPyRestoreThread();
Py_DECREF(m_tagHandlerClass);
m_tagHandlerClass = NULL;
for (size_t x=0; x < m_objArray.GetCount(); x++) {
PyObject* obj = (PyObject*)m_objArray.Item(x);
Py_DECREF(obj);
}
wxPySaveThread(doSave);
};
void FillHandlersTable(wxHtmlWinParser *parser) {
@ -229,6 +231,7 @@ IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
if (m_myInst.findCallback("OnLinkClicked")) {
PyObject* obj = wxPyConstructObject((void*)&link, "wxHtmlLinkInfo");
m_myInst.callCallback(Py_BuildValue("(O)", obj));
Py_DECREF(obj);
}
else
wxHtmlWindow::OnLinkClicked(link);
@ -6273,6 +6276,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxBusyInfo","_class_wxBusyInfo",0},
{ "_class_wxMenuEvent","_wxMenuEvent",0},
{ "_wxPaletteChangedEvent","_class_wxPaletteChangedEvent",0},
{ "_wxJoystick","_class_wxJoystick",0},
{ "_class_wxPyBitmapDataObject","_wxPyBitmapDataObject",0},
{ "_wxClientDC","_class_wxClientDC",0},
{ "_wxMouseEvent","_class_wxMouseEvent",0},
@ -6469,6 +6473,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxHtmlParser","_wxHtmlWinParser",SwigwxHtmlWinParserTowxHtmlParser},
{ "_wxHtmlParser","_class_wxHtmlParser",0},
{ "_class_wxBusyInfo","_wxBusyInfo",0},
{ "_class_wxJoystick","_wxJoystick",0},
{ "_class_wxCommandEvent","_wxCommandEvent",0},
{ "_class_wxClientDC","_wxClientDC",0},
{ "_class_wxSizeEvent","_wxSizeEvent",0},

View File

@ -3188,6 +3188,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxBusyInfo","_class_wxBusyInfo",0},
{ "_class_wxMenuEvent","_wxMenuEvent",0},
{ "_wxPaletteChangedEvent","_class_wxPaletteChangedEvent",0},
{ "_wxJoystick","_class_wxJoystick",0},
{ "_class_wxPyBitmapDataObject","_wxPyBitmapDataObject",0},
{ "_wxClientDC","_class_wxClientDC",0},
{ "_wxMouseEvent","_class_wxMouseEvent",0},
@ -3382,6 +3383,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_class_wxCheckListBox","_wxCheckListBox",0},
{ "_wxHtmlParser","_class_wxHtmlParser",0},
{ "_class_wxBusyInfo","_wxBusyInfo",0},
{ "_class_wxJoystick","_wxJoystick",0},
{ "_class_wxCommandEvent","_wxCommandEvent",0},
{ "_class_wxClientDC","_wxClientDC",0},
{ "_class_wxSizeEvent","_wxSizeEvent",0},

View File

@ -121,7 +121,9 @@ static char* wxStringErrorMsg = "string type is required for parameter";
bool doSave = wxPyRestoreThread();
wxRect* newRect = new wxRect(dest);
obj = wxPyConstructObject((void*)newRect, "wxRect");
PyObject_SetAttrString(obj, "thisown", PyInt_FromLong(1));
PyObject* one = PyInt_FromLong(1);
PyObject_SetAttrString(obj, "thisown", one);
Py_DECREF(one);
wxPySaveThread(doSave);
return obj;
}

View File

@ -400,8 +400,10 @@ public:
if (!PyObject_HasAttrString(py, name))
return NULL;
PyObject* o = PyObject_GetAttrString(py, name);
if (!PyMethod_Check(o) && !PyCFunction_Check(o))
if (!PyMethod_Check(o) && !PyCFunction_Check(o)) {
Py_DECREF(o);
return NULL;
}
return o;
}

View File

@ -264,7 +264,7 @@ static char* wxStringErrorMsg = "string type is required for parameter";
//---------------------------------------------------------------------------
// Typemap to convert strings to wxColour. Two string formats are accepted,
// either a colour name, for a hex colour spec like "#RRGGBB"
// either a colour name, or a hex colour spec like "#RRGGBB"
%typemap(python,in) wxColour& (wxColour temp) {
$target = &temp;

View File

@ -67,7 +67,9 @@
Py_DECREF(arg);
// set ThisOwn
PyObject_SetAttrString($target, "thisown", PyInt_FromLong(1));
PyObject* one = PyInt_FromLong(1);
PyObject_SetAttrString($target, "thisown", one);
Py_DECREF(one);
}
} else {
Py_INCREF(Py_None);
@ -371,8 +373,10 @@ public:
if (!PyObject_HasAttrString(py, name))
return NULL;
PyObject* o = PyObject_GetAttrString(py, name);
if (!PyMethod_Check(o) && !PyCFunction_Check(o))
if (!PyMethod_Check(o) && !PyCFunction_Check(o)) {
Py_DECREF(o);
return NULL;
}
return o;
}

View File

@ -52,7 +52,7 @@
//---------------------------------------------------------------------------
#define __version__ "0.0.0" // The real value is now in build.py...
#define __version__ "0.0.0" // The real value is now in setup.py...
wxPoint wxPyDefaultPosition;
wxSize wxPyDefaultSize;