Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-04-11 11:35:46 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-04-11 11:36:49 +0400
commitb7b4f94e782f7e74c5acf0af19dfda07fdd92568 (patch)
tree700bcf546c6a40c01998a07ed7fa60e8bb53e8eb /source/blender/freestyle/intern/system/PythonInterpreter.h
parent52a5d58045ae2cc3eccbb936e87054eeb75967e2 (diff)
Fix for Freestyle Python API modules not found in the Python Console.
Addition of the path to the Freestyle Python API modules to 'sys.path' was delayed until the first Freestyle rendering, so that any import attempt of the modules in the Python Console always failed. Now the update of 'sys.path' is done at Blender start-up. This allows the Freestyle-specific modules to be imported without running Freestyle, facilitating quick interactive testing in the Console.
Diffstat (limited to 'source/blender/freestyle/intern/system/PythonInterpreter.h')
-rw-r--r--source/blender/freestyle/intern/system/PythonInterpreter.h61
1 files changed, 1 insertions, 60 deletions
diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h
index 30ee6d30163..069fbcfb022 100644
--- a/source/blender/freestyle/intern/system/PythonInterpreter.h
+++ b/source/blender/freestyle/intern/system/PythonInterpreter.h
@@ -60,12 +60,6 @@ public:
_language = "Python";
_context = 0;
memset(&_freestyle_bmain, 0, sizeof(Main));
- //Py_Initialize();
- }
-
- virtual ~PythonInterpreter()
- {
- //Py_Finalize();
}
void setContext(bContext *C)
@@ -75,8 +69,6 @@ public:
int interpretFile(const string& filename)
{
- initPath();
-
ReportList *reports = CTX_wm_reports(_context);
BKE_reports_clear(reports);
char *fn = const_cast<char*>(filename.c_str());
@@ -112,8 +104,6 @@ public:
int interpretText(struct Text *text, const string& name)
{
- initPath();
-
ReportList *reports = CTX_wm_reports(_context);
BKE_reports_clear(reports);
@@ -131,63 +121,14 @@ public:
return 0;
}
- struct Options
- {
- static void setPythonPath(const string& path)
- {
- _path = path;
- }
-
- static string getPythonPath()
- {
- return _path;
- }
- };
-
void reset()
{
- Py_Finalize();
- Py_Initialize();
- _initialized = false;
+ // nothing to do
}
private:
bContext *_context;
Main _freestyle_bmain;
-
- void initPath()
- {
- if (_initialized)
- return;
-
- vector<string> pathnames;
- StringUtils::getPathName(_path, "", pathnames);
-
- struct Text *text = BKE_text_add(&_freestyle_bmain, "tmp_freestyle_initpath.txt");
- string cmd = "import sys\n";
- txt_insert_buf(text, const_cast<char*>(cmd.c_str()));
-
- for (vector<string>::const_iterator it = pathnames.begin(); it != pathnames.end(); ++it) {
- if (!it->empty()) {
- if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "Adding Python path: " << *it << endl;
- }
- cmd = "sys.path.append(r\"" + *it + "\")\n";
- txt_insert_buf(text, const_cast<char *>(cmd.c_str()));
- }
- }
-
- BPY_text_exec(_context, text, NULL, false);
-
- // cleaning up
- BKE_text_unlink(&_freestyle_bmain, text);
- BKE_libblock_free(&_freestyle_bmain, text);
-
- _initialized = true;
- }
-
- static bool _initialized;
- static string _path;
};
} /* namespace Freestyle */