[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45609] trunk/blender/source/blender/ python/intern/bpy_interface.c: Fix #30858: UI losing buttons at some random moment after using Blender for a

Brecht Van Lommel brechtvanlommel at pandora.be
Fri Apr 13 18:03:53 CEST 2012


Revision: 45609
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45609
Author:   blendix
Date:     2012-04-13 16:03:52 +0000 (Fri, 13 Apr 2012)
Log Message:
-----------
Fix #30858: UI losing buttons at some random moment after using Blender for a
while. This may not fix all cases but should at least solve the issue when
rendering with cycles.

The cause was a race condition on C->data.recursion, with multiple threads
accessing context at the same time. Cycles itself does not access context
from the render thread, but the bpy api would do a context update for any
callback in case e.g. a new file got loaded. Disabled that now in non-main
threads.

The ideal solution would be to not allow any context access at all from threads
but that's not so simple to implement, especially not this close to release.

Modified Paths:
--------------
    trunk/blender/source/blender/python/intern/bpy_interface.c

Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c	2012-04-13 15:33:29 UTC (rev 45608)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c	2012-04-13 16:03:52 UTC (rev 45609)
@@ -95,6 +95,12 @@
 /* use for updating while a python script runs - in case of file load */
 void bpy_context_update(bContext *C)
 {
+	/* don't do this from a non-main (e.g. render) thread, it can cause a race
+	   condition on C->data.recursion. ideal solution would be to disable
+	   context entirely from non-main threads, but that's more complicated */
+	if(!BLI_thread_is_main())
+		return;
+
 	BPy_SetContext(C);
 	bpy_import_main_set(CTX_data_main(C));
 	BPY_modules_update(C); /* can give really bad results if this isn't here */




More information about the Bf-blender-cvs mailing list