[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38290] trunk/blender/source: run WM_exit( C) when blender as a python module exits
Campbell Barton
ideasman42 at gmail.com
Sun Jul 10 20:54:03 CEST 2011
Revision: 38290
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38290
Author: campbellbarton
Date: 2011-07-10 18:54:02 +0000 (Sun, 10 Jul 2011)
Log Message:
-----------
run WM_exit(C) when blender as a python module exits
Modified Paths:
--------------
trunk/blender/source/blender/python/intern/bpy_interface.c
trunk/blender/source/creator/creator.c
Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c 2011-07-10 18:21:40 UTC (rev 38289)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c 2011-07-10 18:54:02 UTC (rev 38290)
@@ -663,7 +663,9 @@
#include "BLI_storage.h"
/* TODO, reloading the module isnt functional at the moment. */
-extern int main_python(int argc, const char **argv);
+static void bpy_module_free(void *mod);
+extern int main_python_enter(int argc, const char **argv);
+extern void main_python_exit(void);
static struct PyModuleDef bpy_proxy_def= {
PyModuleDef_HEAD_INIT,
"bpy", /* m_name */
@@ -673,8 +675,8 @@
NULL, /* m_reload */
NULL, /* m_traverse */
NULL, /* m_clear */
- NULL, /* m_free */
-};
+ bpy_module_free, /* m_free */
+};
typedef struct {
PyObject_HEAD
@@ -699,7 +701,7 @@
// printf("module found %s\n", argv[0]);
- main_python(argc, argv);
+ main_python_enter(argc, argv);
/* initialized in BPy_init_modules() */
PyDict_Update(PyModule_GetDict(bpy_proxy), PyModule_GetDict(bpy_package_py));
@@ -756,4 +758,9 @@
return bpy_proxy;
}
+static void bpy_module_free(void *UNUSED(mod))
+{
+ main_python_exit();
+}
+
#endif
Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c 2011-07-10 18:21:40 UTC (rev 38289)
+++ trunk/blender/source/creator/creator.c 2011-07-10 18:54:02 UTC (rev 38290)
@@ -1134,7 +1134,8 @@
#ifdef WITH_PYTHON_MODULE
/* allow python module to call main */
-#define main main_python
+#define main main_python_enter
+static void *evil_C= NULL;
#endif
int main(int argc, const char **argv)
@@ -1145,6 +1146,7 @@
#ifdef WITH_PYTHON_MODULE
#undef main
+ evil_C= C;
#endif
#ifdef WITH_BINRELOC
@@ -1313,6 +1315,14 @@
return 0;
} /* end of int main(argc,argv) */
+#ifdef WITH_PYTHON_MODULE
+void main_python_exit(void)
+{
+ WM_exit((bContext *)evil_C);
+ evil_C= NULL;
+}
+#endif
+
static void error_cb(const char *err)
{
More information about the Bf-blender-cvs
mailing list