Correctly handle the release of ownership of the wx.FSFile returned

from wx.FileSystemHandler.OpenFile.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39703 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2006-06-13 22:25:33 +00:00
parent f2f8871a2e
commit e2e2649fab
2 changed files with 17 additions and 13 deletions

View File

@@ -1628,7 +1628,7 @@ extern wxPyApp *wxPythonApp;
bool CLASS::CBNAME() const { \ bool CLASS::CBNAME() const { \
bool rval=false; \ bool rval=false; \
bool found; \ bool found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \ wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
wxPyEndBlockThreads(blocked); \ wxPyEndBlockThreads(blocked); \
@@ -1647,7 +1647,7 @@ extern wxPyApp *wxPythonApp;
wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
int rval=0; \ int rval=0; \
bool found; \ bool found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \ wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\ rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
wxPyEndBlockThreads(blocked); \ wxPyEndBlockThreads(blocked); \
@@ -1663,7 +1663,7 @@ extern wxPyApp *wxPythonApp;
#define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \ #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \ wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \ wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
wxFSFile* rval=0; \ wxFSFile* rval=0; \
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
PyObject* ro; \ PyObject* ro; \
@@ -1673,6 +1673,8 @@ extern wxPyApp *wxPythonApp;
obj, s)); \ obj, s)); \
if (ro) { \ if (ro) { \
wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \ wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
/* release ownership of the C++ wx.FSFile object. */ \
PyObject_SetAttrString(ro, "thisown", Py_False); \
Py_DECREF(ro); \ Py_DECREF(ro); \
} \ } \
Py_DECREF(obj); \ Py_DECREF(obj); \
@@ -1692,7 +1694,7 @@ extern wxPyApp *wxPythonApp;
bool CLASS::CBNAME(wxDragResult a) { \ bool CLASS::CBNAME(wxDragResult a) { \
bool rval=false; \ bool rval=false; \
bool found; \ bool found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \ wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \ rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
wxPyEndBlockThreads(blocked); \ wxPyEndBlockThreads(blocked); \
@@ -1709,7 +1711,7 @@ extern wxPyApp *wxPythonApp;
#define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \ #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \ wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
int rval=0; \ int rval=0; \
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\ rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\

View File

@@ -26,13 +26,15 @@
class wxFSFile : public wxObject class wxFSFile : public wxObject
{ {
public: public:
%pythonAppend wxFSFile %typemap(out) wxFSFile*; // turn off this typemap
"self.thisown = 0 # It will normally be deleted by the user of the wx.FileSystem";
wxFSFile(wxInputStream *stream, const wxString& loc, wxFSFile(wxInputStream *stream, const wxString& loc,
const wxString& mimetype, const wxString& anchor, const wxString& mimetype, const wxString& anchor,
wxDateTime modif); wxDateTime modif);
// Turn it back on.
%typemap(out) wxFSFile* { $result = wxPyMake_wxObject($1, $owner); }
~wxFSFile(); ~wxFSFile();
wxInputStream *GetStream(); wxInputStream *GetStream();