Cleanup: get rid of just-added G.main usage.
authorBastien Montagne <montagne29@wanadoo.fr>
Wed, 6 Jun 2018 14:32:09 +0000 (16:32 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Wed, 6 Jun 2018 14:32:09 +0000 (16:32 +0200)
Was just added to ease merging of master, proper code now!

source/blender/editors/include/ED_screen.h
source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/screen/workspace_edit.c
source/blender/editors/screen/workspace_layout_edit.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_window.c

index f10e103..cd1fb1f 100644 (file)
@@ -211,10 +211,12 @@ void ED_workspace_view_layer_unset(
         const struct Main *bmain, struct Scene *scene,
         const ViewLayer *layer_unset, ViewLayer *layer_new) ATTR_NONNULL(1, 2);
 struct WorkSpaceLayout *ED_workspace_layout_add(
+        struct Main *bmain,
         struct WorkSpace *workspace,
         struct wmWindow *win,
         const char *name) ATTR_NONNULL();
 struct WorkSpaceLayout *ED_workspace_layout_duplicate(
+        struct Main *bmain,
         struct WorkSpace *workspace, const struct WorkSpaceLayout *layout_old,
         struct wmWindow *win) ATTR_NONNULL();
 bool ED_workspace_layout_delete(
index 2aa48a1..ec2cb64 100644 (file)
@@ -1399,6 +1399,7 @@ void ED_screen_full_restore(bContext *C, ScrArea *sa)
  */
 ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const short state)
 {
+       Main *bmain = CTX_data_main(C);
        wmWindowManager *wm = CTX_wm_manager(C);
        WorkSpace *workspace = WM_window_get_active_workspace(win);
        bScreen *sc, *oldscreen;
@@ -1489,7 +1490,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
                oldscreen->state = state;
                BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name + 2, "nonnormal");
 
-               layout_new = ED_workspace_layout_add(workspace, win, newname);
+               layout_new = ED_workspace_layout_add(bmain, workspace, win, newname);
 
                sc = BKE_workspace_layout_screen_get(layout_new);
                sc->state = state;
index e504a11..f6bd238 100644 (file)
@@ -1069,6 +1069,7 @@ static void SCREEN_OT_area_swap(wmOperatorType *ot)
 /* operator callback */
 static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
+       Main *bmain = CTX_data_main(C);
        wmWindow *newwin, *win = CTX_wm_window(C);
        Scene *scene;
        WorkSpace *workspace = WM_window_get_active_workspace(win);
@@ -1110,7 +1111,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 
        WM_window_set_active_workspace(newwin, workspace);
        /* allocs new screen and adds to newly created window, using window size */
-       layout_new = ED_workspace_layout_add(workspace, newwin, BKE_workspace_layout_name_get(layout_old));
+       layout_new = ED_workspace_layout_add(bmain, workspace, newwin, BKE_workspace_layout_name_get(layout_old));
        newsc = BKE_workspace_layout_screen_get(layout_new);
        WM_window_set_active_layout(newwin, workspace, layout_new);
 
@@ -4301,12 +4302,13 @@ static void SCREEN_OT_drivers_editor_show(struct wmOperatorType *ot)
 
 static int screen_new_exec(bContext *C, wmOperator *UNUSED(op))
 {
+       Main *bmain = CTX_data_main(C);
        wmWindow *win = CTX_wm_window(C);
        WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
        WorkSpaceLayout *layout_old = BKE_workspace_active_layout_get(win->workspace_hook);
        WorkSpaceLayout *layout_new;
 
-       layout_new = ED_workspace_layout_duplicate(workspace, layout_old, win);
+       layout_new = ED_workspace_layout_duplicate(bmain, workspace, layout_old, win);
        WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTBROWSE, layout_new);
 
        return OPERATOR_FINISHED;
index d54996b..a044a7d 100644 (file)
@@ -131,7 +131,7 @@ static bool workspace_change_find_new_layout_cb(const WorkSpaceLayout *layout, v
 }
 
 static WorkSpaceLayout *workspace_change_get_new_layout(
-        WorkSpace *workspace_new, wmWindow *win)
+        Main *bmain, WorkSpace *workspace_new, wmWindow *win)
 {
        /* ED_workspace_duplicate may have stored a layout to activate once the workspace gets activated. */
        WorkSpaceLayout *layout_new;
@@ -155,7 +155,7 @@ static WorkSpaceLayout *workspace_change_get_new_layout(
                                                   NULL, false);
                if (!layout_temp) {
                        /* fallback solution: duplicate layout */
-                       layout_temp = ED_workspace_layout_duplicate(workspace_new, layout_new, win);
+                       layout_temp = ED_workspace_layout_duplicate(bmain, workspace_new, layout_new, win);
                }
                layout_new = layout_temp;
        }
@@ -177,7 +177,7 @@ bool ED_workspace_change(
 {
        Main *bmain = CTX_data_main(C);
        WorkSpace *workspace_old = WM_window_get_active_workspace(win);
-       WorkSpaceLayout *layout_new = workspace_change_get_new_layout(workspace_new, win);
+       WorkSpaceLayout *layout_new = workspace_change_get_new_layout(bmain, workspace_new, win);
        bScreen *screen_new = BKE_workspace_layout_screen_get(layout_new);
        bScreen *screen_old = BKE_workspace_active_screen_get(win->workspace_hook);
 
@@ -228,7 +228,7 @@ WorkSpace *ED_workspace_duplicate(
        /* TODO(campbell): tools */
 
        for (WorkSpaceLayout *layout_old = layouts_old->first; layout_old; layout_old = layout_old->next) {
-               WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(workspace_new, layout_old, win);
+               WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(bmain, workspace_new, layout_old, win);
 
                if (layout_active_old == layout_old) {
                        win->workspace_hook->temp_layout_store = layout_new;
index 4cb88b7..0c7431c 100644 (file)
@@ -46,6 +46,7 @@
  * Empty screen, with 1 dummy area without spacedata. Uses window size.
  */
 WorkSpaceLayout *ED_workspace_layout_add(
+        Main *bmain,
         WorkSpace *workspace,
         wmWindow *win,
         const char *name)
@@ -54,12 +55,13 @@ WorkSpaceLayout *ED_workspace_layout_add(
        rcti screen_rect;
 
        WM_window_screen_rect_calc(win, &screen_rect);
-       screen = screen_add(G.main, name, &screen_rect);
+       screen = screen_add(bmain, name, &screen_rect);
 
        return BKE_workspace_layout_add(workspace, screen, name);
 }
 
 WorkSpaceLayout *ED_workspace_layout_duplicate(
+        Main *bmain,
         WorkSpace *workspace, const WorkSpaceLayout *layout_old,
         wmWindow *win)
 {
@@ -72,7 +74,7 @@ WorkSpaceLayout *ED_workspace_layout_duplicate(
                return NULL; /* XXX handle this case! */
        }
 
-       layout_new = ED_workspace_layout_add(workspace, win, name);
+       layout_new = ED_workspace_layout_add(bmain, workspace, win, name);
        screen_new = BKE_workspace_layout_screen_get(layout_new);
        screen_data_copy(screen_new, screen_old);
 
index 315a3d7..28c47a4 100644 (file)
@@ -215,6 +215,7 @@ static void wm_window_match_keep_current_wm(
         const bool load_ui,
         ListBase *r_new_wm_list)
 {
+       Main *bmain = CTX_data_main(C);
        wmWindowManager *wm = current_wm_list->first;
        bScreen *screen = NULL;
 
@@ -236,7 +237,7 @@ static void wm_window_match_keep_current_wm(
                        }
                        else {
                                WorkSpaceLayout *layout_old = WM_window_get_active_layout(win);
-                               WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(workspace, layout_old, win);
+                               WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(bmain, workspace, layout_old, win);
 
                                WM_window_set_active_layout(win, workspace, layout_new);
                        }
index afe24bb..676bcb1 100644 (file)
@@ -288,6 +288,7 @@ static wmWindow *wm_window_new_test(bContext *C)
 /* part of wm_window.c api */
 wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_layout)
 {
+       Main *bmain = CTX_data_main(C);
        wmWindow *win_dst = wm_window_new(C);
        WorkSpace *workspace = WM_window_get_active_workspace(win_src);
        WorkSpaceLayout *layout_old = WM_window_get_active_layout(win_src);
@@ -301,7 +302,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_la
 
        win_dst->scene = scene;
        WM_window_set_active_workspace(win_dst, workspace);
-       layout_new = duplicate_layout ? ED_workspace_layout_duplicate(workspace, layout_old, win_dst) : layout_old;
+       layout_new = duplicate_layout ? ED_workspace_layout_duplicate(bmain, workspace, layout_old, win_dst) : layout_old;
        WM_window_set_active_layout(win_dst, workspace, layout_new);
 
        *win_dst->stereo3d_format = *win_src->stereo3d_format;
@@ -906,7 +907,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
        if (screen == NULL) {
                /* add new screen layout */
                WorkSpace *workspace = WM_window_get_active_workspace(win);
-               WorkSpaceLayout *layout = ED_workspace_layout_add(workspace, win, "temp");
+               WorkSpaceLayout *layout = ED_workspace_layout_add(bmain, workspace, win, "temp");
 
                screen = BKE_workspace_layout_screen_get(layout);
                WM_window_set_active_layout(win, workspace, layout);
@@ -1031,6 +1032,7 @@ static WorkSpaceLayout *wm_window_new_find_layout(wmOperator *op, WorkSpace *wor
 /* new window operator callback */
 int wm_window_new_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain = CTX_data_main(C);
        wmWindow *win_src = CTX_wm_window(C);
        WorkSpace *workspace = WM_window_get_active_workspace(win_src);
        WorkSpaceLayout *layout_new = wm_window_new_find_layout(op, workspace);
@@ -1040,7 +1042,7 @@ int wm_window_new_exec(bContext *C, wmOperator *op)
        if ((win_dst = wm_window_new_test(C))) {
                if (screen_new->winid) {
                        /* layout/screen is already used, duplicate it */
-                       layout_new = ED_workspace_layout_duplicate(workspace, layout_new, win_dst);
+                       layout_new = ED_workspace_layout_duplicate(bmain, workspace, layout_new, win_dst);
                        screen_new = BKE_workspace_layout_screen_get(layout_new);
                }
                /* New window with a different screen but same workspace */