bugfix [#24333] Horizon Color Picker Crashes Blender if Two 3D View Windows are Open

also added api function ED_area_tag_redraw_regiontype(), so an area can redraw all regions by type.
In this case there is a view3d area listener that needs to draw all WINDOW regions.
This commit is contained in:
Campbell Barton 2010-10-20 04:12:01 +00:00
parent 00b7422f9b
commit c2aa5d6dc0
4 changed files with 59 additions and 40 deletions

@ -78,6 +78,7 @@ void ED_area_exit(struct bContext *C, struct ScrArea *sa);
int ED_screen_area_active(const struct bContext *C);
void ED_area_do_listen(ScrArea *sa, struct wmNotifier *note);
void ED_area_tag_redraw(ScrArea *sa);
void ED_area_tag_redraw_regiontype(ScrArea *sa, int type);
void ED_area_tag_refresh(ScrArea *sa);
void ED_area_do_refresh(struct bContext *C, ScrArea *sa);
void ED_area_headerprint(ScrArea *sa, char *str);

@ -668,6 +668,7 @@ static int parent_set_exec(bContext *C, wmOperator *op)
DAG_scene_sort(bmain, scene);
DAG_ids_flush_update(bmain, 0);
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL);
return OPERATOR_FINISHED;
}

@ -405,6 +405,19 @@ void ED_area_tag_redraw(ScrArea *sa)
ED_region_tag_redraw(ar);
}
void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype)
{
ARegion *ar;
if(sa) {
for(ar= sa->regionbase.first; ar; ar= ar->next) {
if(ar->regiontype == regiontype) {
ED_region_tag_redraw(ar);
}
}
}
}
void ED_area_tag_refresh(ScrArea *sa)
{
if(sa)

@ -559,25 +559,9 @@ static void view3d_recalc_used_layers(ARegion *ar, wmNotifier *wmn, Scene *scene
}
}
static View3D *view3d_from_wmn(ARegion *ar, wmNotifier *wmn)
{
wmWindow *win= wmn->wm->winactive;
ScrArea *sa;
for(sa= win->screen->areabase.first; sa; sa= sa->next) {
if(sa->spacetype == SPACE_VIEW3D)
if(BLI_findindex(&sa->regionbase, ar) != -1) {
return (View3D *)sa->spacedata.first;
}
}
return NULL;
}
static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
{
bScreen *sc;
View3D *v3d;
/* context changes */
switch(wmn->category) {
@ -615,9 +599,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
ED_region_tag_redraw(ar);
break;
case ND_WORLD:
v3d= view3d_from_wmn(ar, wmn);
if(v3d->flag2 & V3D_RENDER_OVERRIDE)
ED_region_tag_redraw(ar);
/* handled by space_view3d_listener() for v3d access */
break;
}
if (wmn->action == NA_EDITED)
@ -669,9 +651,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
case NC_WORLD:
switch(wmn->data) {
case ND_WORLD_DRAW:
v3d= view3d_from_wmn(ar, wmn);
if(v3d->flag2 & V3D_RENDER_OVERRIDE)
ED_region_tag_redraw(ar);
/* handled by space_view3d_listener() for v3d access */
break;
}
break;
@ -910,6 +890,47 @@ static void view3d_props_area_listener(ARegion *ar, wmNotifier *wmn)
}
}
/*area (not region) level listener*/
void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn)
{
View3D *v3d = sa->spacedata.first;
/* context changes */
switch(wmn->category) {
case NC_SCENE:
switch(wmn->data) {
case ND_WORLD:
if(v3d->flag2 & V3D_RENDER_OVERRIDE)
ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW);
break;
}
break;
case NC_WORLD:
switch(wmn->data) {
case ND_WORLD_DRAW:
if(v3d->flag2 & V3D_RENDER_OVERRIDE)
ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW);
break;
}
break;
}
#if 0 // removed since BKE_image_user_calc_frame is now called in draw_bgpic because screen_ops doesnt call the notifier.
if (wmn->category == NC_SCENE && wmn->data == ND_FRAME) {
View3D *v3d = area->spacedata.first;
BGpic *bgpic = v3d->bgpicbase.first;
for (; bgpic; bgpic = bgpic->next) {
if (bgpic->ima) {
Scene *scene = wmn->reference;
BKE_image_user_calc_frame(&bgpic->iuser, scene->r.cfra, 0);
}
}
}
#endif
}
static int view3d_context(const bContext *C, const char *member, bContextDataResult *result)
{
View3D *v3d= CTX_wm_view3d(C);
@ -1012,23 +1033,6 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
return -1; /* found but not available */
}
/*area (not region) level listener*/
#if 0 // removed since BKE_image_user_calc_frame is now called in draw_bgpic because screen_ops doesnt call the notifier.
void space_view3d_listener(struct ScrArea *area, struct wmNotifier *wmn)
{
if (wmn->category == NC_SCENE && wmn->data == ND_FRAME) {
View3D *v3d = area->spacedata.first;
BGpic *bgpic = v3d->bgpicbase.first;
for (; bgpic; bgpic = bgpic->next) {
if (bgpic->ima) {
Scene *scene = wmn->reference;
BKE_image_user_calc_frame(&bgpic->iuser, scene->r.cfra, 0);
}
}
}
}
#endif
/* only called once, from space/spacetypes.c */
void ED_spacetype_view3d(void)
@ -1042,7 +1046,7 @@ void ED_spacetype_view3d(void)
st->new= view3d_new;
st->free= view3d_free;
st->init= view3d_init;
// st->listener = space_view3d_listener;
st->listener = space_view3d_listener;
st->duplicate= view3d_duplicate;
st->operatortypes= view3d_operatortypes;
st->keymap= view3d_keymap;