From 124942a13b842f287b531f20fef30e2e6de768ef Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 19 Dec 2010 07:56:41 +0000 Subject: [PATCH] Finally fix those darn Maya crashes --- dtool/src/dtoolutil/executionEnvironment.cxx | 2 +- pandatool/src/mayaprogs/mayaWrapper.cxx | 5 +++++ pandatool/src/mayaprogs/mayapath.cxx | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx index 65b254f243..0ccbf59c30 100644 --- a/dtool/src/dtoolutil/executionEnvironment.cxx +++ b/dtool/src/dtoolutil/executionEnvironment.cxx @@ -229,7 +229,7 @@ ns_get_environment_variable(const string &var) const { } else if (var == "MAIN_DIR") { #ifdef HAVE_PYTHON // If we're running from Python code, read out sys.argv. - if (Py_IsInitialized()) { + if (!ns_has_environment_variable("PANDA_INCOMPATIBLE_PYTHON") && Py_IsInitialized()) { PyObject* obj = PySys_GetObject((char*) "argv"); if (obj) { Filename main_dir = Filename::from_os_specific(PyString_AsString(PyList_GetItem(obj, 0))); diff --git a/pandatool/src/mayaprogs/mayaWrapper.cxx b/pandatool/src/mayaprogs/mayaWrapper.cxx index 5eda7f43f3..47b64e8692 100644 --- a/pandatool/src/mayaprogs/mayaWrapper.cxx +++ b/pandatool/src/mayaprogs/mayaWrapper.cxx @@ -320,6 +320,11 @@ int main(int argc, char **argv) _putenv(env1); _putenv(env2); #endif // _WIN32 + + // When this is set, Panda3D will try not to use any functions from the + // CPython API. This is necessary because Maya links with its own copy + // of Python, which may be incompatible with ours. + _putenv("PANDA_INCOMPATIBLE_PYTHON=1"); #ifdef _WIN32 STARTUPINFO si; PROCESS_INFORMATION pi; diff --git a/pandatool/src/mayaprogs/mayapath.cxx b/pandatool/src/mayaprogs/mayapath.cxx index bd16ac137c..cfda657dc2 100755 --- a/pandatool/src/mayaprogs/mayapath.cxx +++ b/pandatool/src/mayaprogs/mayapath.cxx @@ -157,6 +157,11 @@ main(int argc, char *argv[]) { #endif // IS_OSX + // When this is set, Panda3D will try not to use any functions from the + // CPython API. This is necessary because Maya links with its own copy + // of Python, which may be incompatible with ours. + putenv("PANDA_INCOMPATIBLE_PYTHON=1"); + // Now that we have set up the environment variables properly, chain // to the actual maya2egg_bin (or whichever) executable.