Skip to content

Commit e21a057

Browse files
committed
More GIL fixes for the console
1 parent 448f87a commit e21a057

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

PythonScript/src/PythonConsole.cpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ void PythonConsole::initPython(PythonHandler *pythonHandler)
121121
void PythonConsole::pythonShowDialog()
122122
{
123123
assert(mp_consoleDlg);
124+
GILRelease release;
124125
if (mp_consoleDlg)
125126
{
126127
// Post the message to ourselves (on the right thread) to create the window
127128
if (!mp_consoleDlg->isCreated())
128129
{
129-
GILRelease release;
130130
CommunicationInfo commInfo;
131131
commInfo.internalMsg = PYSCR_SHOWCONSOLE;
132132
commInfo.srcModuleName = _T("PythonScript.dll");
@@ -277,23 +277,26 @@ void PythonConsole::queueComplete()
277277

278278
void PythonConsole::consume(std::shared_ptr<std::string> statement)
279279
{
280-
GILLock gilLock;
281-
282280
bool continuePrompt = false;
283-
try
284-
{
285-
boost::python::object oldStdout = m_sys.attr("stdout");
286-
m_sys.attr("stdout") = boost::python::ptr(this);
287-
PyObject* unicodeCommand = PyUnicode_FromEncodedObject(boost::python::str(statement->c_str()).ptr(), "utf-8", NULL);
288-
boost::python::object result = m_pushFunc(boost::python::handle<PyObject>(unicodeCommand));
289-
//Py_DECREF(unicodeCommand);
290-
m_sys.attr("stdout") = oldStdout;
291-
292-
continuePrompt = boost::python::extract<bool>(result);
293-
}
294-
catch(...)
295281
{
296-
PyErr_Print();
282+
GILLock gilLock;
283+
284+
try
285+
{
286+
boost::python::object oldStdout = m_sys.attr("stdout");
287+
m_sys.attr("stdout") = boost::python::ptr(this);
288+
PyObject* unicodeCommand = PyUnicode_FromEncodedObject(boost::python::str(statement->c_str()).ptr(), "utf-8", NULL);
289+
boost::python::object result = m_pushFunc(boost::python::handle<PyObject>(unicodeCommand));
290+
//Py_DECREF(unicodeCommand);
291+
m_sys.attr("stdout") = oldStdout;
292+
293+
continuePrompt = boost::python::extract<bool>(result);
294+
}
295+
catch(...)
296+
{
297+
PyErr_Print();
298+
}
299+
297300
}
298301

299302
assert(mp_consoleDlg);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _PYTHONSCRIPTVERSION_H
22
#define _PYTHONSCRIPTVERSION_H
33

4-
#define PYSCR_VERSION_NUMERIC 1,0,9,0
5-
#define PYSCR_VERSION_STRING "1.0.9.0"
4+
#define PYSCR_VERSION_NUMERIC 1,1,1,0
5+
#define PYSCR_VERSION_STRING "1.1.1.0"
66

77
#endif

0 commit comments

Comments
 (0)