From 85ae4b87afa80527a36d3bd3164a9df6544f0c3b Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Tue, 28 Apr 2015 23:18:32 +0900 Subject: 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. --- .../freestyle/intern/system/PythonInterpreter.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source/blender/freestyle/intern/system') 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); -- cgit v1.2.3