bugfix [#24333] Horizon Color Picker Crashes Blender if Two 3D View Windows are Open
authorCampbell Barton <ideasman42@gmail.com>
Wed, 20 Oct 2010 04:12:01 +0000 (04:12 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 20 Oct 2010 04:12:01 +0000 (04:12 +0000)
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.

source/blender/editors/include/ED_screen.h
source/blender/editors/object/object_relations.c
source/blender/editors/screen/area.c
source/blender/editors/space_view3d/space_view3d.c

index 62243a0e53ede579729afdfa0de32f5596bb3678..8b8bb75b8e6aa1d6759cca64b0db86e33af97f92 100644 (file)
@@ -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);
index 14f88c6d99e917dff3e65ccdc513471ed44756cb..d92aeb13547c92e9ee787d038062623e60091c69 100644 (file)
@@ -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;
 }
index ae1388fb7f2e1b9d3a77229c034d886ba948ced2..7838fbdd5f45a124103cf0ffe7e1eb809494e3fb 100644 (file)
@@ -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)
index c1a07914b77e4d869c03bb2c5d252047899d1e68..77f6e63e860b0afcf15268aefbaecf050f622181 100644 (file)
@@ -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;