fix [#33836] issuing bpy.ops.render.render() in console crashes the program

don't check the event queue from threads, assert if this happens in future.
This commit is contained in:
Campbell Barton 2013-01-22 02:21:21 +00:00
parent 044e3398b9
commit 2cd25f4cf5
2 changed files with 25 additions and 4 deletions

@ -73,6 +73,7 @@
#include "render_intern.h"
/* Render Callbacks */
static int render_break(void *rjv);
/* called inside thread! */
void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volatile rcti *renrect)
@ -210,7 +211,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
lay = (v3d) ? v3d->lay : scene->lay;
G.is_break = FALSE;
RE_test_break_cb(re, NULL, (int (*)(void *))blender_test_break);
RE_test_break_cb(re, NULL, render_break);
ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
@ -443,6 +444,15 @@ static int render_breakjob(void *rjv)
return 0;
}
/* for exec() when there is no render job
* note: this wont check for the escape key being pressed, but doing so isnt threadsafe */
static int render_break(void *UNUSED(rjv))
{
if (G.is_break)
return 1;
return 0;
}
/* runs in thread, no cursor setting here works. careful with notifiers too (malloc conflicts) */
/* maybe need a way to get job send notifer? */
static void render_drawlock(void *UNUSED(rjv), int lock)

@ -75,6 +75,11 @@
#include "UI_interface.h"
/* for assert */
#ifndef NDEBUG
# include "BLI_threads.h"
#endif
/* the global to talk to ghost */
static GHOST_SystemHandle g_system = NULL;
@ -1036,8 +1041,12 @@ static int wm_window_timer(const bContext *C)
void wm_window_process_events(const bContext *C)
{
int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
int hasevent;
BLI_assert(BLI_thread_is_main());
hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
if (hasevent)
GHOST_DispatchEvents(g_system);
@ -1059,7 +1068,9 @@ void wm_window_testbreak(void)
{
static double ltime = 0;
double curtime = PIL_check_seconds_timer();
BLI_assert(BLI_thread_is_main());
/* only check for breaks every 50 milliseconds
* if we get called more often.
*/