Code cleanup: remove redundant CTX calls
authorCampbell Barton <ideasman42@gmail.com>
Tue, 29 Apr 2014 21:48:54 +0000 (07:48 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 29 Apr 2014 22:11:47 +0000 (08:11 +1000)
21 files changed:
source/blender/editors/interface/view2d_ops.c
source/blender/editors/mesh/editmesh_loopcut.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_group.c
source/blender/editors/object/object_select.c
source/blender/editors/render/render_view.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_image_proj.c
source/blender/editors/space_clip/clip_ops.c
source/blender/editors/space_clip/space_clip.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_text/text_autocomplete.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/space_view3d/view3d_walk.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_window.c

index af43a10..e30c6ca 100644 (file)
@@ -1033,7 +1033,7 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even
 
        if (U.viewzoom == USER_ZOOM_CONT) {
                /* needs a timer to continue redrawing */
-               vzd->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f);
+               vzd->timer = WM_event_add_timer(CTX_wm_manager(C), window, TIMER, 0.01f);
                vzd->timer_lastdraw = PIL_check_seconds_timer();
        }
 
index e52ec8d..4ef6c13 100644 (file)
@@ -415,7 +415,7 @@ static int ringsel_init(bContext *C, wmOperator *op, bool do_cut)
        lcd->num.unit_type[1] = B_UNIT_NONE;
 
        /* XXX, temp, workaround for [# ] */
-       EDBM_mesh_ensure_valid_dm_hack(CTX_data_scene(C), lcd->em);
+       EDBM_mesh_ensure_valid_dm_hack(scene, lcd->em);
 
        em_setup_viewcontext(C, &lcd->vc);
 
index da989ba..cfd3469 100644 (file)
@@ -1028,7 +1028,7 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op)
                /* create new data for NLA hierarchy */
                AnimData *adt = BKE_id_add_animdata(&ob->id);
                NlaTrack *nlt = add_nlatrack(adt, NULL);
-               NlaStrip *strip = add_nla_soundstrip(CTX_data_scene(C), ob->data);
+               NlaStrip *strip = add_nla_soundstrip(scene, ob->data);
                strip->start = CFRA;
                strip->end += strip->start;
 
index 8a8881f..cb89cdc 100644 (file)
@@ -209,7 +209,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op)
                DAG_id_type_tag(bmain, ID_OB);
                DAG_relations_tag_update(bmain);
                
-               WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
+               WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
                
        }
 
index bfaf7f1..5bd057f 100644 (file)
@@ -476,7 +476,7 @@ static int group_link_exec(bContext *C, wmOperator *op)
        Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
        Object *ob = ED_object_context(C);
-       Group *group = BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group"));
+       Group *group = BLI_findlink(&bmain->group, RNA_enum_get(op->ptr, "group"));
 
        if (ELEM(NULL, ob, group))
                return OPERATOR_CANCELLED;
index 41ca4bf..a0350cf 100644 (file)
@@ -486,7 +486,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
                return OPERATOR_CANCELLED;
 
        if (changed) {
-               WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
+               WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
                return OPERATOR_FINISHED;
        }
        
@@ -862,7 +862,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op)
        else if (nr == 14) changed |= select_similar_pass_index(C, ob);
 
        if (changed) {
-               WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
+               WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
                return OPERATOR_FINISHED;
        }
        
@@ -1099,7 +1099,7 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op)
        CTX_DATA_END;
        
        /* undo? */
-       WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
+       WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
        
        return OPERATOR_FINISHED;
 }
index 80ce74f..09b8273 100644 (file)
@@ -167,11 +167,12 @@ ScrArea *render_view_open(bContext *C, int mx, int my)
                sa = CTX_wm_area(C);
        }
        else if (scene->r.displaymode == R_OUTPUT_SCREEN) {
-               if (CTX_wm_area(C) && CTX_wm_area(C)->spacetype == SPACE_IMAGE)
-                       area_was_image = 1;
+               sa = CTX_wm_area(C);
+               if (sa && sa->spacetype == SPACE_IMAGE)
+                       area_was_image = true;
 
                /* this function returns with changed context */
-               sa = ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE);
+               sa = ED_screen_full_newspace(C, sa, SPACE_IMAGE);
        }
 
        if (!sa) {
@@ -239,8 +240,8 @@ static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(op))
        SpaceImage *sima = sa->spacedata.first;
 
        /* test if we have a temp screen in front */
-       if (CTX_wm_window(C)->screen->temp) {
-               wm_window_lower(CTX_wm_window(C));
+       if (win->screen->temp) {
+               wm_window_lower(win);
                return OPERATOR_FINISHED;
        }
        /* determine if render already shows */
index 586c784..1b850d6 100644 (file)
@@ -738,7 +738,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
                        /* gesture is large enough? */
                        if (is_gesture) {
                                /* second area, for join when (sa1 != sa2) */
-                               sad->sa2 = screen_areahascursor(CTX_wm_screen(C), event->x, event->y);
+                               sad->sa2 = screen_areahascursor(sc, event->x, event->y);
                                /* apply sends event */
                                actionzone_apply(C, op, sad->az->type);
                                actionzone_exit(op);
@@ -1999,7 +1999,7 @@ static int frame_offset_exec(bContext *C, wmOperator *op)
        
        sound_seek_scene(bmain, scene);
 
-       WM_event_add_notifier(C, NC_SCENE | ND_FRAME, CTX_data_scene(C));
+       WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
        
        return OPERATOR_FINISHED;
 }
@@ -3093,7 +3093,7 @@ static int header_toggle_menus_exec(bContext *C, wmOperator *UNUSED(op))
 
        sa->flag = sa->flag ^ HEADER_NO_PULLDOWN;
 
-       ED_area_tag_redraw(CTX_wm_area(C));
+       ED_area_tag_redraw(sa);
        WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);  
 
        return OPERATOR_FINISHED;
index 6961064..87e707b 100644 (file)
@@ -911,7 +911,7 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event
 
        RNA_int_set_array(op->ptr, "location", event->mval);
        paint_sample_color(C, ar, event->mval[0], event->mval[1]);
-       WM_cursor_modal_set(CTX_wm_window(C), BC_EYEDROPPER_CURSOR);
+       WM_cursor_modal_set(win, BC_EYEDROPPER_CURSOR);
 
        WM_event_add_modal_handler(C, op);
        WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
index e691ecd..791d9f7 100644 (file)
@@ -4425,7 +4425,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
        if (w > maxsize) w = maxsize;
        if (h > maxsize) h = maxsize;
 
-       ibuf = ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, false, R_ALPHAPREMUL, err_out);
+       ibuf = ED_view3d_draw_offscreen_imbuf(scene, CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, false, R_ALPHAPREMUL, err_out);
        if (!ibuf) {
                /* Mostly happens when OpenGL offscreen buffer was failed to create, */
                /* but could be other reasons. Should be handled in the future. nazgul */
index 6ef4b12..ae2bf7e 100644 (file)
@@ -780,7 +780,7 @@ static int view_all_exec(bContext *C, wmOperator *op)
 
        sc->xof = sc->yof = 0.0f;
 
-       ED_region_tag_redraw(CTX_wm_region(C));
+       ED_region_tag_redraw(ar);
 
        return OPERATOR_FINISHED;
 }
@@ -814,7 +814,7 @@ static int view_selected_exec(bContext *C, wmOperator *UNUSED(op))
        sc->ylockof = 0.0f;
 
        ED_clip_view_selection(C, ar, 1);
-       ED_region_tag_redraw(CTX_wm_region(C));
+       ED_region_tag_redraw(ar);
 
        return OPERATOR_FINISHED;
 }
@@ -852,7 +852,7 @@ static void change_frame_apply(bContext *C, wmOperator *op)
        SUBFRA = 0.0f;
 
        /* do updates */
-       sound_seek_scene(CTX_data_main(C), CTX_data_scene(C));
+       sound_seek_scene(CTX_data_main(C), scene);
        WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
 }
 
@@ -1286,7 +1286,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
        G.is_break = false;
        WM_jobs_start(CTX_wm_manager(C), wm_job);
 
-       ED_area_tag_redraw(CTX_wm_area(C));
+       ED_area_tag_redraw(sa);
 
        return OPERATOR_FINISHED;
 }
index b2af3c4..5eb60b1 100644 (file)
@@ -1317,7 +1317,7 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar)
 
        /* time grid */
        unit = (sc->flag & SC_SHOW_SECONDS) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
-       grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP,
+       grid = UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP,
                                   V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
        UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
        UI_view2d_grid_free(grid);
index 1cc416c..04269e0 100644 (file)
@@ -1440,7 +1440,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
        clip = ED_space_clip_get_clip(sc);
        framenr = ED_space_clip_get_clip_frame_number(sc);
 
-       if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY)) {
+       if (WM_jobs_test(CTX_wm_manager(C), sa, WM_JOB_TYPE_ANY)) {
                /* only one tracking is allowed at a time */
                return OPERATOR_CANCELLED;
        }
@@ -1716,7 +1716,7 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
        wmJob *wm_job;
        char error_msg[256] = "\0";
 
-       if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY)) {
+       if (WM_jobs_test(CTX_wm_manager(C), sa, WM_JOB_TYPE_ANY)) {
                /* only one solve is allowed at a time */
                return OPERATOR_CANCELLED;
        }
@@ -3062,7 +3062,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
 
        if (CFRA != sc->user.framenr) {
                CFRA = sc->user.framenr;
-               sound_seek_scene(CTX_data_main(C), CTX_data_scene(C));
+               sound_seek_scene(CTX_data_main(C), scene);
 
                WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
        }
index 031dcdd..1d3013b 100644 (file)
@@ -1060,7 +1060,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
                }
        }
        
-       ED_region_tag_redraw(CTX_wm_region(C));
+       ED_region_tag_redraw(ar);
        
        /* and restore context */
        CTX_wm_region_set(C, oldar);
@@ -1147,7 +1147,7 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
        BLI_strncpy(sfile->params->renamefile, name, FILE_MAXFILE);
 
        /* set timer to smoothly view newly generated file */
-       sfile->smoothscroll_timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER1, 1.0 / 1000.0);    /* max 30 frs/sec */
+       sfile->smoothscroll_timer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER1, 1.0 / 1000.0);  /* max 30 frs/sec */
        sfile->scroll_offset = 0;
 
        /* reload dir to make sure we're seeing what's in the directory */
index 0fd1523..0a6f86a 100644 (file)
@@ -440,7 +440,7 @@ static int image_view_zoom_exec(bContext *C, wmOperator *op)
 
        sima_zoom_set_factor(sima, ar, RNA_float_get(op->ptr, "factor"), NULL);
 
-       ED_region_tag_redraw(CTX_wm_region(C));
+       ED_region_tag_redraw(ar);
 
        /* XXX notifier? */
 #if 0
@@ -477,7 +477,7 @@ static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
                factor = 1.0f + delta / 300.0f;
                RNA_float_set(op->ptr, "factor", factor);
                sima_zoom_set(sima, ar, sima->zoom * factor, location);
-               ED_region_tag_redraw(CTX_wm_region(C));
+               ED_region_tag_redraw(ar);
                
                return OPERATOR_FINISHED;
        }
@@ -685,7 +685,7 @@ static int image_view_all_exec(bContext *C, wmOperator *op)
 
        sima->xof = sima->yof = 0.0f;
 
-       ED_region_tag_redraw(CTX_wm_region(C));
+       ED_region_tag_redraw(ar);
        
        return OPERATOR_FINISHED;
 }
@@ -748,7 +748,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
        if (size <= 0.01f) size = 0.01f;
        sima_zoom_set(sima, ar, 0.7f / size, NULL);
 
-       ED_region_tag_redraw(CTX_wm_region(C));
+       ED_region_tag_redraw(ar);
        
        return OPERATOR_FINISHED;
 }
@@ -782,7 +782,7 @@ static int image_view_zoom_in_exec(bContext *C, wmOperator *op)
 
        sima_zoom_set_factor(sima, ar, powf(2.0f, 1.0f / 3.0f), location);
 
-       ED_region_tag_redraw(CTX_wm_region(C));
+       ED_region_tag_redraw(ar);
        
        return OPERATOR_FINISHED;
 }
@@ -827,7 +827,7 @@ static int image_view_zoom_out_exec(bContext *C, wmOperator *op)
 
        sima_zoom_set_factor(sima, ar, powf(0.5f, 1.0f / 3.0f), location);
        
-       ED_region_tag_redraw(CTX_wm_region(C));
+       ED_region_tag_redraw(ar);
        
        return OPERATOR_FINISHED;
 }
@@ -884,7 +884,7 @@ static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op)
        }
 #endif
 
-       ED_region_tag_redraw(CTX_wm_region(C));
+       ED_region_tag_redraw(ar);
        
        return OPERATOR_FINISHED;
 }
@@ -2901,7 +2901,7 @@ static void change_frame_apply(bContext *C, wmOperator *op)
        SUBFRA = 0.0f;
 
        /* do updates */
-       sound_seek_scene(CTX_data_main(C), CTX_data_scene(C));
+       sound_seek_scene(CTX_data_main(C), scene);
        WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
 }
 
index 9b15036..212bc5b 100644 (file)
@@ -219,7 +219,7 @@ static void seq_proxy_build_job(const bContext *C)
                WM_jobs_start(CTX_wm_manager(C), wm_job);
        }
 
-       ED_area_tag_redraw(CTX_wm_area(C));
+       ED_area_tag_redraw(sa);
 }
 
 /* ********************************************************************** */
index e2948fc..99e1606 100644 (file)
@@ -494,7 +494,7 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
        }
 
        if (draw) {
-               ED_area_tag_redraw(CTX_wm_area(C));
+               ED_area_tag_redraw(sa);
        }
 
 //     if (swallow) {
index 7c8d588..6e68fc2 100644 (file)
@@ -1408,7 +1408,7 @@ static int localview_exec(bContext *C, wmOperator *op)
 
        if (changed) {
                DAG_id_type_tag(bmain, ID_OB);
-               ED_area_tag_redraw(CTX_wm_area(C));
+               ED_area_tag_redraw(sa);
 
                return OPERATOR_FINISHED;
        }
index fa395c9..8180ac1 100644 (file)
@@ -543,7 +543,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
 
        copy_v2_v2_int(walk->prev_mval, walk->center_mval);
 
-       WM_cursor_warp(CTX_wm_window(C),
+       WM_cursor_warp(win,
                       walk->ar->winrct.xmin + walk->center_mval[0],
                       walk->ar->winrct.ymin + walk->center_mval[1]);
 
index 768e40e..6cd4b89 100644 (file)
@@ -340,7 +340,7 @@ static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event)
                                                }
                                        }
 
-                                       WM_cursor_grab_enable(CTX_wm_window(C), wrap, false, bounds);
+                                       WM_cursor_grab_enable(win, wrap, false, bounds);
                                }
                        }
                }
index e850b4f..44e31f4 100644 (file)
@@ -831,7 +831,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
 
                                /* stop screencast if resize */
                                if (type == GHOST_kEventWindowSize) {
-                                       WM_jobs_stop(CTX_wm_manager(C), win->screen, NULL);
+                                       WM_jobs_stop(wm, win->screen, NULL);
                                }
                                
                                /* win32: gives undefined window size when minimized */