]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/msw/streams.cpp
Move [GS]etDefaultItem up to wxWindow
[wxWidgets.git] / wxPython / src / msw / streams.cpp
index ca8e59dc22e3e465185d36600a368a8298666ac4..fbd7f643710523cc202dfe2f9786735c0317b589 100644 (file)
@@ -142,14 +142,12 @@ wxString* wxPyInputStream::read(int size) {
         }
 
         // read until EOF
         }
 
         // read until EOF
-        wxPy_BEGIN_ALLOW_THREADS;
         while (! wxi->Eof()) {
             wxi->Read(buf, BUFSIZE);
             //*s += wxString(buf, wxi->LastRead());
             s->Append(buf, wxi->LastRead());
         }
         delete buf;
         while (! wxi->Eof()) {
             wxi->Read(buf, BUFSIZE);
             //*s += wxString(buf, wxi->LastRead());
             s->Append(buf, wxi->LastRead());
         }
         delete buf;
-        wxPy_END_ALLOW_THREADS;
 
         // error check
         if (wxi->LastError() == wxSTREAM_READ_ERROR) {
 
         // error check
         if (wxi->LastError() == wxSTREAM_READ_ERROR) {
@@ -166,10 +164,8 @@ wxString* wxPyInputStream::read(int size) {
         }
 
         // read size bytes
         }
 
         // read size bytes
-        wxPy_BEGIN_ALLOW_THREADS;
         wxi->Read(s->GetWriteBuf(size+1), size);
         s->UngetWriteBuf(wxi->LastRead());
         wxi->Read(s->GetWriteBuf(size+1), size);
         s->UngetWriteBuf(wxi->LastRead());
-        wxPy_END_ALLOW_THREADS;
 
         // error check
         if (wxi->LastError() == wxSTREAM_READ_ERROR) {
 
         // error check
         if (wxi->LastError() == wxSTREAM_READ_ERROR) {
@@ -199,11 +195,9 @@ wxString* wxPyInputStream::readline (int size) {
     }
 
     // read until \n or byte limit reached
     }
 
     // read until \n or byte limit reached
-    wxPy_BEGIN_ALLOW_THREADS;
     for (i=ch=0; (ch != '\n') && (!wxi->Eof()) && ((size < 0) || (i < size)); i++) {
         *s += ch = wxi->GetC();
     }
     for (i=ch=0; (ch != '\n') && (!wxi->Eof()) && ((size < 0) || (i < size)); i++) {
         *s += ch = wxi->GetC();
     }
-    wxPy_END_ALLOW_THREADS;
 
     // errorcheck
     if (wxi->LastError() == wxSTREAM_READ_ERROR) {
 
     // errorcheck
     if (wxi->LastError() == wxSTREAM_READ_ERROR) {
@@ -230,7 +224,6 @@ wxStringPtrList* wxPyInputStream::readlines (int sizehint) {
     }
 
     // read sizehint bytes or until EOF
     }
 
     // read sizehint bytes or until EOF
-    wxPy_BEGIN_ALLOW_THREADS;
     int i;
     for (i=0; (!wxi->Eof()) && ((sizehint < 0) || (i < sizehint));) {
         wxString* s = readline();
     int i;
     for (i=0; (!wxi->Eof()) && ((sizehint < 0) || (i < sizehint));) {
         wxString* s = readline();
@@ -242,7 +235,6 @@ wxStringPtrList* wxPyInputStream::readlines (int sizehint) {
         l->Append(s);
         i = i + s->Length();
     }
         l->Append(s);
         i = i + s->Length();
     }
-    wxPy_END_ALLOW_THREADS;
 
     // error check
     if (wxi->LastError() == wxSTREAM_READ_ERROR) {
 
     // error check
     if (wxi->LastError() == wxSTREAM_READ_ERROR) {
@@ -279,7 +271,7 @@ protected:
         if (bufsize == 0)
             return 0;
 
         if (bufsize == 0)
             return 0;
 
-        wxPyTState* state = wxPyBeginBlockThreads();
+        wxPyBeginBlockThreads();
         PyObject* arglist = Py_BuildValue("(i)", bufsize);
         PyObject* result = PyEval_CallObject(read, arglist);
         Py_DECREF(arglist);
         PyObject* arglist = Py_BuildValue("(i)", bufsize);
         PyObject* result = PyEval_CallObject(read, arglist);
         Py_DECREF(arglist);
@@ -297,7 +289,7 @@ protected:
         }
         else
             m_lasterror = wxSTREAM_READ_ERROR;
         }
         else
             m_lasterror = wxSTREAM_READ_ERROR;
-        wxPyEndBlockThreads(state);
+        wxPyEndBlockThreads();
         m_lastcount = o;
         return o;
     }
         m_lastcount = o;
         return o;
     }
@@ -308,17 +300,17 @@ protected:
     }
 
     virtual off_t OnSysSeek(off_t off, wxSeekMode mode){
     }
 
     virtual off_t OnSysSeek(off_t off, wxSeekMode mode){
-        wxPyTState* state = wxPyBeginBlockThreads();
+        wxPyBeginBlockThreads();
         PyObject*arglist = Py_BuildValue("(ii)", off, mode);
         PyObject*result = PyEval_CallObject(seek, arglist);
         Py_DECREF(arglist);
         Py_XDECREF(result);
         PyObject*arglist = Py_BuildValue("(ii)", off, mode);
         PyObject*result = PyEval_CallObject(seek, arglist);
         Py_DECREF(arglist);
         Py_XDECREF(result);
-        wxPyEndBlockThreads(state);
+        wxPyEndBlockThreads();
         return OnSysTell();
     }
 
     virtual off_t OnSysTell() const{
         return OnSysTell();
     }
 
     virtual off_t OnSysTell() const{
-        wxPyTState* state = wxPyBeginBlockThreads();
+        wxPyBeginBlockThreads();
         PyObject* arglist = Py_BuildValue("()");
         PyObject* result = PyEval_CallObject(tell, arglist);
         Py_DECREF(arglist);
         PyObject* arglist = Py_BuildValue("()");
         PyObject* result = PyEval_CallObject(tell, arglist);
         Py_DECREF(arglist);
@@ -327,7 +319,7 @@ protected:
             o = PyInt_AsLong(result);
             Py_DECREF(result);
         };
             o = PyInt_AsLong(result);
             Py_DECREF(result);
         };
-        wxPyEndBlockThreads(state);
+        wxPyEndBlockThreads();
         return o;
     }
 
         return o;
     }
 
@@ -337,12 +329,12 @@ protected:
 
 public:
     ~wxPyCBInputStream() {
 
 public:
     ~wxPyCBInputStream() {
-        wxPyTState* state = wxPyBeginBlockThreads();
+        wxPyBeginBlockThreads();
         Py_XDECREF(py);
         Py_XDECREF(read);
         Py_XDECREF(seek);
         Py_XDECREF(tell);
         Py_XDECREF(py);
         Py_XDECREF(read);
         Py_XDECREF(seek);
         Py_XDECREF(tell);
-        wxPyEndBlockThreads(state);
+        wxPyEndBlockThreads();
     }
 
     virtual size_t GetSize() {
     }
 
     virtual size_t GetSize() {
@@ -422,8 +414,11 @@ static PyObject *_wrap_new_wxInputStream(PyObject *self, PyObject *args, PyObjec
   _arg0 = _obj0;
 }
 {
   _arg0 = _obj0;
 }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         _result = (wxPyInputStream *)new_wxPyInputStream(_arg0);
 
         _result = (wxPyInputStream *)new_wxPyInputStream(_arg0);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }    if (_result) {
         SWIG_MakePtr(_ptemp, (char *) _result,"_wxPyInputStream_p");
         _resultobj = Py_BuildValue("s",_ptemp);
 }    if (_result) {
         SWIG_MakePtr(_ptemp, (char *) _result,"_wxPyInputStream_p");
         _resultobj = Py_BuildValue("s",_ptemp);
@@ -452,8 +447,11 @@ static PyObject *_wrap_wxInputStream_close(PyObject *self, PyObject *args, PyObj
         }
     }
 {
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         wxInputStream_close(_arg0);
 
         wxInputStream_close(_arg0);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }    Py_INCREF(Py_None);
     _resultobj = Py_None;
     return _resultobj;
 }    Py_INCREF(Py_None);
     _resultobj = Py_None;
     return _resultobj;
@@ -477,8 +475,11 @@ static PyObject *_wrap_wxInputStream_flush(PyObject *self, PyObject *args, PyObj
         }
     }
 {
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         wxInputStream_flush(_arg0);
 
         wxInputStream_flush(_arg0);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }    Py_INCREF(Py_None);
     _resultobj = Py_None;
     return _resultobj;
 }    Py_INCREF(Py_None);
     _resultobj = Py_None;
     return _resultobj;
@@ -503,8 +504,11 @@ static PyObject *_wrap_wxInputStream_eof(PyObject *self, PyObject *args, PyObjec
         }
     }
 {
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         _result = (bool )wxInputStream_eof(_arg0);
 
         _result = (bool )wxInputStream_eof(_arg0);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }    _resultobj = Py_BuildValue("i",_result);
     return _resultobj;
 }
 }    _resultobj = Py_BuildValue("i",_result);
     return _resultobj;
 }
@@ -529,15 +533,13 @@ static PyObject *_wrap_wxInputStream_read(PyObject *self, PyObject *args, PyObje
         }
     }
 {
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         _result = (wxString *)wxInputStream_read(_arg0,_arg1);
 
         _result = (wxString *)wxInputStream_read(_arg0,_arg1);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }{
 }{
-    if (_result) {
-        _resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len());
-        delete _result;
-    }
-    else
-        _resultobj=0;
+    _resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len());
 }
     return _resultobj;
 }
 }
     return _resultobj;
 }
@@ -562,15 +564,13 @@ static PyObject *_wrap_wxInputStream_readline(PyObject *self, PyObject *args, Py
         }
     }
 {
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         _result = (wxString *)wxInputStream_readline(_arg0,_arg1);
 
         _result = (wxString *)wxInputStream_readline(_arg0,_arg1);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }{
 }{
-    if (_result) {
-        _resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len());
-        delete _result;
-    }
-    else
-        _resultobj=0;
+    _resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len());
 }
     return _resultobj;
 }
 }
     return _resultobj;
 }
@@ -595,8 +595,11 @@ static PyObject *_wrap_wxInputStream_readlines(PyObject *self, PyObject *args, P
         }
     }
 {
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         _result = (wxStringPtrList *)wxInputStream_readlines(_arg0,_arg1);
 
         _result = (wxStringPtrList *)wxInputStream_readlines(_arg0,_arg1);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }{
     if (_result) {
         _resultobj = PyList_New(_result->GetCount());
 }{
     if (_result) {
         _resultobj = PyList_New(_result->GetCount());
@@ -635,8 +638,11 @@ static PyObject *_wrap_wxInputStream_seek(PyObject *self, PyObject *args, PyObje
         }
     }
 {
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         wxInputStream_seek(_arg0,_arg1,_arg2);
 
         wxInputStream_seek(_arg0,_arg1,_arg2);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }    Py_INCREF(Py_None);
     _resultobj = Py_None;
     return _resultobj;
 }    Py_INCREF(Py_None);
     _resultobj = Py_None;
     return _resultobj;
@@ -661,8 +667,11 @@ static PyObject *_wrap_wxInputStream_tell(PyObject *self, PyObject *args, PyObje
         }
     }
 {
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         _result = (int )wxInputStream_tell(_arg0);
 
         _result = (int )wxInputStream_tell(_arg0);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }    _resultobj = Py_BuildValue("i",_result);
     return _resultobj;
 }
 }    _resultobj = Py_BuildValue("i",_result);
     return _resultobj;
 }
@@ -707,8 +716,11 @@ static PyObject *_wrap_wxOutputStream_write(PyObject *self, PyObject *args, PyOb
 #endif
 }
 {
 #endif
 }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         wxOutputStream_write(_arg0,*_arg1);
 
         wxOutputStream_write(_arg0,*_arg1);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }    Py_INCREF(Py_None);
     _resultobj = Py_None;
 {
 }    Py_INCREF(Py_None);
     _resultobj = Py_None;
 {