Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix major(?) memory leak with python code execution
(cherry-picked from 73733a6)
- Loading branch information
1 parent
804ac7e
commit 8f0ee1f
Showing
1 changed file
with
4 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -298,9 +298,9 @@ bool QgsPythonUtilsImpl::runStringUnsafe( const QString& command, bool single ) | ||
// TODO: convert special characters from unicode strings u"..." to \uXXXX | ||
// so that they're not mangled to utf-8 | ||
// (non-unicode strings can be mangled) | ||
PyRun_String( command.toUtf8().data(), single ? Py_single_input : Py_file_input, mMainDict, mMainDict ); | ||
|
||
PyObject* obj = PyRun_String( command.toUtf8().data(), single ? Py_single_input : Py_file_input, mMainDict, mMainDict ); | ||
bool res = nullptr == PyErr_Occurred(); | ||
Py_DECREF( obj ); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
elpaso
Contributor
|
||
|
||
// we are done calling python API, release global interpreter lock | ||
PyGILState_Release( gstate ); | ||
@@ -581,6 +581,8 @@ bool QgsPythonUtilsImpl::evalString( const QString& command, QString& result ) | ||
if ( success ) | ||
result = PyObjectToQString( res ); | ||
|
||
Py_XDECREF( res ); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
// we are done calling python API, release global interpreter lock | ||
PyGILState_Release( gstate ); | ||
|
||
Segfault here with 2.14.3
test with
qgis --code 'some_not_existant_path.py'