[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12908] trunk/blender: * Added an option not to compile the 2.4x api ( WITH_PYAPI_V24X for Makefiles and WITH_BF_PYAPI_V24X for scons)

Campbell Barton ideasman42 at gmail.com
Sun Dec 16 07:50:49 CET 2007


Revision: 12908
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12908
Author:   campbellbarton
Date:     2007-12-16 07:50:49 +0100 (Sun, 16 Dec 2007)

Log Message:
-----------
* Added an option not to compile the 2.4x api (WITH_PYAPI_V24X for Makefiles and WITH_BF_PYAPI_V24X for scons)
* ghash wasnt being set to null when python stopped and was segfaulting on exit

Modified Paths:
--------------
    trunk/blender/source/blender/python/BPY_interface.c
    trunk/blender/source/blender/python/Makefile
    trunk/blender/source/blender/python/SConscript
    trunk/blender/source/nan_definitions.mk
    trunk/blender/tools/btools.py

Modified: trunk/blender/source/blender/python/BPY_interface.c
===================================================================
--- trunk/blender/source/blender/python/BPY_interface.c	2007-12-16 05:46:24 UTC (rev 12907)
+++ trunk/blender/source/blender/python/BPY_interface.c	2007-12-16 06:50:49 UTC (rev 12908)
@@ -75,7 +75,9 @@
 #include "api2_5x/bpy.h" /* for the new "bpy" module */
 
 /* old 2.4x api */
+#ifdef WITH_PYAPI_V24X
 #include "api2_4x/Blender.h"
+#endif
 
 /*these next two are for pyconstraints*/
 #include "api2_5x/IDProp.h"
@@ -319,8 +321,10 @@
  * support for packages here e.g. import `package.module` */
 
 static struct _inittab BPyInittab_Modules[] = {
+	{"bpy", m_bpy_init},
+#ifdef WITH_PYAPI_V24X
 	{"Blender", V24_M_Blender_Init},
-	{"bpy", m_bpy_init},
+#endif
 	{NULL, NULL}
 };
 
@@ -396,9 +400,9 @@
 void BPY_idhash_remove(ID *id)
 {
 	GHash *hash = idhash__internal(id);
-	if (!hash) /* TODO - Dont allow invalid hashes at all*/
+	if (hash==NULL)
 		return;
-	printf("remove hash %s\n", id->name);
+	//printf("remove hash %s\n", id->name);
 	BLI_ghash_remove(hash, id, NULL, NULL);
 }
 
@@ -412,10 +416,10 @@
 {
 	GHash *hash = idhash__internal(id);
 	
-	if (!hash) /* TODO - Dont allow invalid hashes */
+	if (hash==NULL)
 		return;
 	
-	printf("invalidate hash %s\n", id->name);
+	//printf("invalidate hash %s\n", id->name);
 	BLI_ghash_remove(hash, id, NULL, genlib_invalidate);
 	
 }
@@ -424,7 +428,7 @@
 void BPY_idhash_add(void *value)
 {
 	ID *id = ((BPyGenericLibObject *)value)->id;
-	printf("adding hash %s\n", id->name);
+	//printf("adding hash %s\n", id->name);
 	BLI_ghash_insert(idhash__internal(id), (void *)id, (void *)value);
 }	
 /* END OF BPY ID HASH */
@@ -536,10 +540,10 @@
 	EXPP_Library_Close(  );
 
 	// free id hashes
-	BLI_ghash_free(bpy_idhash_text, NULL, NULL);
-	BLI_ghash_free(bpy_idhash_scene, NULL, NULL);
-	BLI_ghash_free(bpy_idhash_group, NULL, NULL);
-	BLI_ghash_free(bpy_idhash_object, NULL, NULL);
+	BLI_ghash_free(bpy_idhash_text, NULL, NULL);	bpy_idhash_text = NULL;
+	BLI_ghash_free(bpy_idhash_scene, NULL, NULL);	bpy_idhash_scene = NULL;
+	BLI_ghash_free(bpy_idhash_group, NULL, NULL);	bpy_idhash_group = NULL;
+	BLI_ghash_free(bpy_idhash_object, NULL, NULL);	bpy_idhash_object = NULL;
 	
 	return;
 }

Modified: trunk/blender/source/blender/python/Makefile
===================================================================
--- trunk/blender/source/blender/python/Makefile	2007-12-16 05:46:24 UTC (rev 12907)
+++ trunk/blender/source/blender/python/Makefile	2007-12-16 06:50:49 UTC (rev 12908)
@@ -32,6 +32,11 @@
 # Bounces make to subdirectories.
 
 SOURCEDIR = source/blender/python
-DIRS = api2_4x api2_5x
 
+DIRS = api2_5x
+
+ifeq ($(WITH_PYAPI_V24X), true)
+	DIRS += api2_4x
+endif
+
 include nan_subdirs.mk

Modified: trunk/blender/source/blender/python/SConscript
===================================================================
--- trunk/blender/source/blender/python/SConscript	2007-12-16 05:46:24 UTC (rev 12907)
+++ trunk/blender/source/blender/python/SConscript	2007-12-16 06:50:49 UTC (rev 12908)
@@ -1,9 +1,9 @@
 #!/usr/bin/python
 Import ('env')
 
-sources = Split('BPY_interface.c BPY_menus.c') + env.Glob('api2_5x/*.c') + env.Glob('api2_4x/*.c')
+sources = Split('BPY_interface.c BPY_menus.c') + env.Glob('api2_5x/*.c')
 
-incs = 'api2_5x api2_4x ../blenkernel ../blenlib ../blenloader'
+incs = 'api2_5x ../blenkernel ../blenlib ../blenloader'
 incs += ' ../render/extern/include ../radiosity/extern/include'
 incs += ' ../makesdna #intern/guardedalloc #intern/bmfont ../imbuf ../include'
 incs += ' ' + env['BF_PYTHON_INC']
@@ -23,4 +23,9 @@
 if env['WITH_BF_FFMPEG'] == 1:
     defs.append('WITH_FFMPEG')
 
+if env['WITH_BF_PYAPI_V24X']==1:
+	defs.append('WITH_PYAPI_V24X')
+	sources += env.Glob('api2_4x/*.c')
+	incs += ' api2_4x'
+
 env.BlenderLib ( libname='blender_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype=['core','game2'], priority = [60,115] )

Modified: trunk/blender/source/nan_definitions.mk
===================================================================
--- trunk/blender/source/nan_definitions.mk	2007-12-16 05:46:24 UTC (rev 12907)
+++ trunk/blender/source/nan_definitions.mk	2007-12-16 06:50:49 UTC (rev 12908)
@@ -112,7 +112,8 @@
 
     export WITH_OPENEXR ?= true
     export WITH_DDS ?= true
-
+	export WITH_PYAPI_V24X ?= true
+	
     ifeq ($(OS),windows)
 	export NAN_WINTAB ?= $(LCGDIR)/wintab
       ifeq ($(FREE_WINDOWS), true)

Modified: trunk/blender/tools/btools.py
===================================================================
--- trunk/blender/tools/btools.py	2007-12-16 05:46:24 UTC (rev 12907)
+++ trunk/blender/tools/btools.py	2007-12-16 06:50:49 UTC (rev 12908)
@@ -46,7 +46,7 @@
             'WITH_BF_QUICKTIME', 'BF_QUICKTIME', 'BF_QUICKTIME_INC', 'BF_QUICKTIME_LIB', 'BF_QUICKTIME_LIBPATH',
             'WITH_BF_STATICOPENGL', 'BF_OPENGL', 'BF_OPENGL_INC', 'BF_OPENGL_LIB', 'BF_OPENGL_LIBPATH', 'BF_OPENGL_LIB_STATIC', 'BF_OPENGL_LINKFLAGS',
             'WITH_BF_FTGL', 'BF_FTGL', 'BF_FTGL_INC', 'BF_FTGL_LIB',
-            'WITH_BF_FFMPEG',
+            'WITH_BF_PYAPI_V24X',
             'WITH_BF_PLAYER',
             'CFLAGS', 'CCFLAGS', 'CPPFLAGS', 
             'REL_CFLAGS', 'REL_CCFLAGS',
@@ -173,6 +173,7 @@
         ('BF_FFMPEG_INC', 'FFMPEG includes', ''),
         ('BF_FFMPEG_LIBPATH', 'FFMPEG library path', ''),
         
+        (BoolOption('WITH_BF_PYAPI_V24X', 'Compile Blender 2.4x python api if true', 'true')),
 
         (BoolOption('WITH_BF_JPEG', 'Use JPEG if true', 'true')),
         ('BF_JPEG', 'JPEG base path', ''),





More information about the Bf-blender-cvs mailing list