diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2015-04-28 17:18:32 +0300 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2015-04-28 18:57:56 +0300 |
commit | 85ae4b87afa80527a36d3bd3164a9df6544f0c3b (patch) | |
tree | dc6dbd0992f9bbf97e4fe39f1df038b005e79d00 /source/blender/freestyle/intern/system/PythonInterpreter.h | |
parent | 7851534541b02a05b8b647be01c726373185f758 (diff) |
Fix T44404: freestyle crashes blender.
The reported crash case seems to be caused by freeing compiled Python
objects in a thread. Now this issue is avoided by allocating a buffer to
store a Python script and using BPY_string_exec() to run the script. This
makes it unnecessary to repeatedly create and destroy Text data blocks.
Many thanks to Campbell Barton for his help on the bug fix.
Diffstat (limited to 'source/blender/freestyle/intern/system/PythonInterpreter.h')
-rw-r--r-- | source/blender/freestyle/intern/system/PythonInterpreter.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h index 60193590944..ddb79b2df0b 100644 --- a/source/blender/freestyle/intern/system/PythonInterpreter.h +++ b/source/blender/freestyle/intern/system/PythonInterpreter.h @@ -51,6 +51,8 @@ extern "C" { #include "BKE_text.h" #include "BPY_extern.h" + +#include "bpy_util.h" } namespace Freestyle { @@ -105,6 +107,26 @@ public: return 0; } + int interpretString(const string& str, const string& name) + { + ReportList *reports = CTX_wm_reports(_context); + + BKE_reports_clear(reports); + + if (BPY_string_exec(_context, str.c_str()) != 0) { + BPy_errors_to_report(reports); + cerr << "\nError executing Python script from PythonInterpreter::interpretString" << endl; + cerr << "Name: " << name << endl; + cerr << "Errors: " << endl; + BKE_reports_print(reports, RPT_ERROR); + return 1; + } + + BKE_reports_clear(reports); + + return 0; + } + int interpretText(struct Text *text, const string& name) { ReportList *reports = CTX_wm_reports(_context); |