[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52283] trunk/blender/source/blender/ blenkernel/intern/context.c: Python/Context: do not allow any UI context access from threads like render

Brecht Van Lommel brechtvanlommel at pandora.be
Fri Nov 16 16:15:40 CET 2012


Revision: 52283
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52283
Author:   blendix
Date:     2012-11-16 15:15:40 +0000 (Fri, 16 Nov 2012)
Log Message:
-----------
Python/Context: do not allow any UI context access from threads like render
or baking. This basically means you will only have access to bpy.data and
bpy.context.scene, not current window, active object, etc, as those are not
thread safe anyway and were likely to cause issues already.

This fixes #30858, where the UI would lose buttons due to context getting
corrupted when editing objects in pre/post render or using luxrender. The
context access they did (indirectly) was only using the current scene or
data so they still work.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/context.c

Modified: trunk/blender/source/blender/blenkernel/intern/context.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/context.c	2012-11-16 15:09:38 UTC (rev 52282)
+++ trunk/blender/source/blender/blenkernel/intern/context.c	2012-11-16 15:15:40 UTC (rev 52283)
@@ -44,6 +44,7 @@
 
 #include "BLI_listbase.h"
 #include "BLI_string.h"
+#include "BLI_threads.h"
 #include "BLI_utildefines.h"
 
 #include "BKE_context.h"
@@ -245,6 +246,10 @@
 	(void)C, (void)member;
 #endif
 
+	/* don't allow UI context access from non-main threads */
+	if (!BLI_thread_is_main())
+		return NULL;
+
 	return fall_through;
 }
 
@@ -264,6 +269,11 @@
 //			return 1;
 	}
 #endif
+
+	/* don't allow UI context access from non-main threads */
+	if (!BLI_thread_is_main())
+		return done;
+
 	/* we check recursion to ensure that we do not get infinite
 	 * loops requesting data from ourselfs in a context callback */
 




More information about the Bf-blender-cvs mailing list