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.
This commit is contained in:
2015-04-28 23:18:32 +09:00
parent 7851534541
commit 85ae4b87af
5 changed files with 65 additions and 22 deletions

View File

@@ -36,6 +36,34 @@ struct Text;
namespace Freestyle {
class BufferedStyleModule : public StyleModule
{
public:
BufferedStyleModule(const string& buffer, const string& file_name, Interpreter *inter) : StyleModule(file_name, inter)
{
_buffer = buffer;
}
virtual ~BufferedStyleModule()
{
}
protected:
virtual int interpret()
{
PythonInterpreter *py_inter = dynamic_cast<PythonInterpreter*>(_inter);
BLI_assert(py_inter != 0);
return py_inter->interpretString(_buffer, getFileName());
}
private:
string _buffer;
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BufferedStyleModule")
#endif
};
class BlenderStyleModule : public StyleModule
{
public:
@@ -62,7 +90,6 @@ private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BlenderStyleModule")
#endif
};
} /* namespace Freestyle */