[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36389] branches/bge_components/source/ blender/blenkernel/intern/python_component.c: Print an error to the user when they only specify and module and not a class .

Mitchell Stokes mogurijin at gmail.com
Sat Apr 30 10:42:32 CEST 2011


Revision: 36389
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36389
Author:   moguri
Date:     2011-04-30 08:42:32 +0000 (Sat, 30 Apr 2011)
Log Message:
-----------
Print an error to the user when they only specify and module and not a class. This also fixes a crash under the same conditions.

Modified Paths:
--------------
    branches/bge_components/source/blender/blenkernel/intern/python_component.c

Modified: branches/bge_components/source/blender/blenkernel/intern/python_component.c
===================================================================
--- branches/bge_components/source/blender/blenkernel/intern/python_component.c	2011-04-30 06:40:39 UTC (rev 36388)
+++ branches/bge_components/source/blender/blenkernel/intern/python_component.c	2011-04-30 08:42:32 UTC (rev 36389)
@@ -263,23 +263,23 @@
 	if (strcmp(import, "") == 0)
 		return NULL;
 
-	state = PyGILState_Ensure();
-
 	// Split the class and module
 	last_dot_str = strrchr(import, '.');
 	last_dot = (int)(last_dot_str-import) + 1;
 
-	if(last_dot)
+
+	if(last_dot > 0)
 	{
 		BLI_strncpy(path, import, last_dot);
 		strcpy(cls, import+last_dot);
 	}
 	else
 	{
-		strcpy(path, import);
-		strcpy(cls, "");
+		printf("No component class was specified, only the module was.\n");
+		return NULL;
 	}
 
+	state = PyGILState_Ensure();
 
 	// Try to load up the module
 	mod = PyImport_ImportModule(path);




More information about the Bf-blender-cvs mailing list