Cleanup: Remove G.main from some editor files.
authorBastien Montagne <montagne29@wanadoo.fr>
Thu, 31 May 2018 16:23:20 +0000 (18:23 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Thu, 31 May 2018 16:23:20 +0000 (18:23 +0200)
source/blender/editors/include/ED_image.h
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/space_image/image_edit.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_text/text_ops.c
source/blender/makesrna/intern/rna_material.c
source/blender/makesrna/intern/rna_sculpt_paint.c
source/blender/makesrna/intern/rna_space.c
source/blenderplayer/bad_level_call_stubs/stubs.c

index 9de550a20ce650dee96d4ca4cb2f2f65a1857d84..5fdcf21304c3a683b484e52cc0104a966ff5076f 100644 (file)
@@ -42,7 +42,8 @@ struct Scene;
 
 /* image_edit.c, exported for transform */
 struct Image *ED_space_image(struct SpaceImage *sima);
-void          ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
+void          ED_space_image_set(
+        struct Main *bmain, struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
 struct Mask  *ED_space_image_get_mask(struct SpaceImage *sima);
 void          ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask);
 
index cb6dba4772f14b6e116404516405d2e40ce36321..ef4f598a6b7a9d71e706b045dc8cb39953f9a120 100644 (file)
@@ -1077,7 +1077,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
                                                        SpaceImage *sima = (SpaceImage *)sl;
                                                        
                                                        if (!sima->pin)
-                                                               ED_space_image_set(sima, scene, scene->obedit, ima);
+                                                               ED_space_image_set(bmain, sima, scene, scene->obedit, ima);
                                                }
                                        }
                                }
index 9d7944a25d3ac4312c9b7a4ba10cbb0ccd755186..383303c9ad0c14da3bad3d84d24b4f49186d700d 100644 (file)
@@ -41,6 +41,7 @@
 #include "BKE_image.h"
 #include "BKE_editmesh.h"
 #include "BKE_library.h"
+#include "BKE_main.h"
 
 #include "IMB_imbuf_types.h"
 
@@ -61,10 +62,10 @@ Image *ED_space_image(SpaceImage *sima)
 }
 
 /* called to assign images to UV faces */
-void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *ima)
+void ED_space_image_set(Main *bmain, SpaceImage *sima, Scene *scene, Object *obedit, Image *ima)
 {
        /* context may be NULL, so use global */
-       ED_uvedit_assign_image(G.main, scene, obedit, ima, sima->image);
+       ED_uvedit_assign_image(bmain, scene, obedit, ima, sima->image);
 
        /* change the space ima after because uvedit_face_visible_test uses the space ima
         * to check if the face is displayed in UV-localview */
index 308ee61a2b8dd1e03b1f302914f106c4f7607978..0e553b11919c2dc23544b54c3a511276e6afa2f7 100644 (file)
@@ -1304,7 +1304,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
        }
        else if (sa && sa->spacetype == SPACE_IMAGE) {
                SpaceImage *sima = sa->spacedata.first;
-               ED_space_image_set(sima, scene, obedit, ima);
+               ED_space_image_set(bmain, sima, scene, obedit, ima);
                iuser = &sima->iuser;
        }
        else if (sa && sa->spacetype == SPACE_VIEW3D) {
@@ -1621,7 +1621,7 @@ static char imtype_best_depth(ImBuf *ibuf, const char imtype)
        }
 }
 
-static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, Scene *scene,
+static int save_image_options_init(Main *bmain, SaveImageOptions *simopts, SpaceImage *sima, Scene *scene,
                                    const bool guess_path, const bool save_as_render)
 {
        void *lock;
@@ -1686,12 +1686,12 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
                                }
                                else {
                                        BLI_strncpy(simopts->filepath, "//untitled", sizeof(simopts->filepath));
-                                       BLI_path_abs(simopts->filepath, G.main->name);
+                                       BLI_path_abs(simopts->filepath, bmain->name);
                                }
                        }
                        else {
                                BLI_snprintf(simopts->filepath, sizeof(simopts->filepath), "//%s", ima->id.name + 2);
-                               BLI_path_abs(simopts->filepath, is_prev_save ? G.ima : G.main->name);
+                               BLI_path_abs(simopts->filepath, is_prev_save ? G.ima : bmain->name);
                        }
                }
 
@@ -1705,7 +1705,7 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
        return (ibuf != NULL);
 }
 
-static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op)
+static void save_image_options_from_op(Main *bmain, SaveImageOptions *simopts, wmOperator *op)
 {
        if (op->customdata) {
                BKE_color_managed_view_settings_free(&simopts->im_format.view_settings);
@@ -1715,7 +1715,7 @@ static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op
 
        if (RNA_struct_property_is_set(op->ptr, "filepath")) {
                RNA_string_get(op->ptr, "filepath", simopts->filepath);
-               BLI_path_abs(simopts->filepath, G.main->name);
+               BLI_path_abs(simopts->filepath, bmain->name);
        }
 }
 
@@ -2048,6 +2048,7 @@ static void image_save_as_free(wmOperator *op)
 
 static int image_save_as_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain = CTX_data_main(C);
        SpaceImage *sima = CTX_wm_space_image(C);
        SaveImageOptions simopts;
 
@@ -2055,9 +2056,9 @@ static int image_save_as_exec(bContext *C, wmOperator *op)
 
        /* just in case to initialize values,
         * these should be set on invoke or by the caller. */
-       save_image_options_init(&simopts, sima, CTX_data_scene(C), false, false);
+       save_image_options_init(bmain, &simopts, sima, CTX_data_scene(C), false, false);
 
-       save_image_options_from_op(&simopts, op);
+       save_image_options_from_op(bmain, &simopts, op);
 
        save_image_doit(C, sima, op, &simopts, true);
 
@@ -2074,6 +2075,7 @@ static bool image_save_as_check(bContext *UNUSED(C), wmOperator *op)
 
 static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 {
+       Main *bmain = CTX_data_main(C);
        SpaceImage *sima = CTX_wm_space_image(C);
        Image *ima = ED_space_image(sima);
        Scene *scene = CTX_data_scene(C);
@@ -2086,7 +2088,7 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
 
        save_image_options_defaults(&simopts);
 
-       if (save_image_options_init(&simopts, sima, scene, true, save_as_render) == 0)
+       if (save_image_options_init(bmain, &simopts, sima, scene, true, save_as_render) == 0)
                return OPERATOR_CANCELLED;
        save_image_options_to_op(&simopts, op);
 
@@ -2197,14 +2199,15 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
 
 static int image_save_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain = CTX_data_main(C);
        SpaceImage *sima = CTX_wm_space_image(C);
        Scene *scene = CTX_data_scene(C);
        SaveImageOptions simopts;
 
        save_image_options_defaults(&simopts);
-       if (save_image_options_init(&simopts, sima, scene, false, false) == 0)
+       if (save_image_options_init(bmain, &simopts, sima, scene, false, false) == 0)
                return OPERATOR_CANCELLED;
-       save_image_options_from_op(&simopts, op);
+       save_image_options_from_op(bmain, &simopts, op);
 
        if (BLI_exists(simopts.filepath) && BLI_file_is_writable(simopts.filepath)) {
                if (save_image_doit(C, sima, op, &simopts, false)) {
@@ -2432,7 +2435,7 @@ static int image_new_exec(bContext *C, wmOperator *op)
                RNA_property_update(C, &ptr, prop);
        }
        else if (sima) {
-               ED_space_image_set(sima, scene, obedit, ima);
+               ED_space_image_set(bmain, sima, scene, obedit, ima);
        }
        else if (gen_context == GEN_CONTEXT_PAINT_CANVAS) {
                bScreen *sc;
@@ -2452,7 +2455,7 @@ static int image_new_exec(bContext *C, wmOperator *op)
                                                SpaceImage *sima_other = (SpaceImage *)sl;
                                                
                                                if (!sima_other->pin) {
-                                                       ED_space_image_set(sima_other, scene, scene->obedit, ima);
+                                                       ED_space_image_set(bmain, sima_other, scene, scene->obedit, ima);
                                                }
                                        }
                                }
@@ -3596,13 +3599,14 @@ void IMAGE_OT_change_frame(wmOperatorType *ot)
 /* goes over all scenes, reads render layers */
 static int image_read_renderlayers_exec(bContext *C, wmOperator *UNUSED(op))
 {
+       Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
        SpaceImage *sima = CTX_wm_space_image(C);
        Image *ima;
 
        ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
        if (sima->image == NULL) {
-               ED_space_image_set(sima, scene, NULL, ima);
+               ED_space_image_set(bmain, sima, scene, NULL, ima);
        }
 
        RE_ReadRenderResult(scene, scene);
index 68338bf233747d2a93becab1faa0c8526e0542fe..24215c6d403b39b7ab75286dc6df6394d1720f7a 100644 (file)
@@ -234,7 +234,7 @@ static int text_open_exec(bContext *C, wmOperator *op)
 
        RNA_string_get(op->ptr, "filepath", str);
 
-       text = BKE_text_load_ex(bmain, str, G.main->name, internal);
+       text = BKE_text_load_ex(bmain, str, bmain->name, internal);
 
        if (!text) {
                if (op->customdata) MEM_freeN(op->customdata);
@@ -272,8 +272,9 @@ static int text_open_exec(bContext *C, wmOperator *op)
 
 static int text_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 {
+       Main *bmain = CTX_data_main(C);
        Text *text = CTX_data_edit_text(C);
-       const char *path = (text && text->name) ? text->name : G.main->name;
+       const char *path = (text && text->name) ? text->name : bmain->name;
 
        if (RNA_struct_property_is_set(op->ptr, "filepath"))
                return text_open_exec(C, op);
@@ -456,7 +457,7 @@ static int text_save_poll(bContext *C)
        return (text->name != NULL && !(text->flags & TXT_ISMEM));
 }
 
-static void txt_write_file(Text *text, ReportList *reports) 
+static void txt_write_file(Main *bmain, Text *text, ReportList *reports)
 {
        FILE *fp;
        TextLine *tmp;
@@ -464,7 +465,7 @@ static void txt_write_file(Text *text, ReportList *reports)
        char filepath[FILE_MAX];
        
        BLI_strncpy(filepath, text->name, FILE_MAX);
-       BLI_path_abs(filepath, G.main->name);
+       BLI_path_abs(filepath, bmain->name);
        
        fp = BLI_fopen(filepath, "w");
        if (fp == NULL) {
@@ -499,9 +500,10 @@ static void txt_write_file(Text *text, ReportList *reports)
 
 static int text_save_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain = CTX_data_main(C);
        Text *text = CTX_data_edit_text(C);
 
-       txt_write_file(text, op->reports);
+       txt_write_file(bmain, text, op->reports);
 
        text_update_cursor_moved(C);
        WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
@@ -525,6 +527,7 @@ void TEXT_OT_save(wmOperatorType *ot)
 
 static int text_save_as_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain = CTX_data_main(C);
        Text *text = CTX_data_edit_text(C);
        char str[FILE_MAX];
 
@@ -537,7 +540,7 @@ static int text_save_as_exec(bContext *C, wmOperator *op)
        text->name = BLI_strdup(str);
        text->flags &= ~TXT_ISMEM;
 
-       txt_write_file(text, op->reports);
+       txt_write_file(bmain, text, op->reports);
 
        text_update_cursor_moved(C);
        WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
@@ -547,6 +550,7 @@ static int text_save_as_exec(bContext *C, wmOperator *op)
 
 static int text_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 {
+       Main *bmain = CTX_data_main(C);
        Text *text = CTX_data_edit_text(C);
        const char *str;
 
@@ -558,7 +562,7 @@ static int text_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
        else if (text->flags & TXT_ISMEM)
                str = text->id.name + 2;
        else
-               str = G.main->name;
+               str = bmain->name;
        
        RNA_string_set(op->ptr, "filepath", str);
        WM_event_add_fileselect(C, op); 
index 1959a017e436251cc67340518d11b1513610ad60..4e86e5c59afc6e17b2b73425e64acc5b6f7e9870 100644 (file)
@@ -207,7 +207,7 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *s
                                                SpaceImage *sima = (SpaceImage *)sl;
                                                
                                                if (!sima->pin)
-                                                       ED_space_image_set(sima, scene, scene->obedit, image);
+                                                       ED_space_image_set(bmain, sima, scene, scene->obedit, image);
                                        }
                                }
                        }
index 6dbfc3634b250916a92901626116f3bcedbdf050..140349ac00364004c4ac360f033e6564bed9fa25 100644 (file)
@@ -388,7 +388,7 @@ static void rna_ImaPaint_canvas_update(Main *bmain, Scene *scene, PointerRNA *UN
                                        SpaceImage *sima = (SpaceImage *)sl;
                                        
                                        if (!sima->pin)
-                                               ED_space_image_set(sima, scene, scene->obedit, ima);
+                                               ED_space_image_set(bmain, sima, scene, scene->obedit, ima);
                                }
                        }
                }
index d6a304f4dfe6873b844011c3aeae62c7638c4b79..6d77f3a91580f9968dd75a624f41ec5ecd7f45eb 100644 (file)
@@ -264,6 +264,7 @@ const EnumPropertyItem rna_enum_file_sort_items[] = {
 #include "BKE_colortools.h"
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
+#include "BKE_global.h"
 #include "BKE_nla.h"
 #include "BKE_paint.h"
 #include "BKE_scene.h"
@@ -835,7 +836,7 @@ static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value)
        SpaceImage *sima = (SpaceImage *)(ptr->data);
        bScreen *sc = (bScreen *)ptr->id.data;
 
-       ED_space_image_set(sima, sc->scene, sc->scene->obedit, (Image *)value.data);
+       ED_space_image_set(G.main, sima, sc->scene, sc->scene->obedit, (Image *)value.data);
 }
 
 static void rna_SpaceImageEditor_mask_set(PointerRNA *ptr, PointerRNA value)
index bf89ffd56371ce46bee1e8b744fc6afb12b63cfb..87259a9c86dddd99615a92d1c51576077901a67f 100644 (file)
@@ -390,7 +390,7 @@ bool ED_space_image_show_uvedit(struct SpaceImage *sima, struct Object *obedit)
 bool ED_space_image_show_render(struct SpaceImage *sima) RET_ZERO
 bool ED_space_image_show_paint(struct SpaceImage *sima) RET_ZERO
 void ED_space_image_paint_update(struct wmWindowManager *wm, struct Scene *scene) RET_NONE
-void ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima) RET_NONE
+void ED_space_image_set(struct Main *bmain, struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima) RET_NONE
 void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct Scene *scene) RET_NONE
 void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *sima, struct ImBuf *ibuf, bool use_view_settings) RET_NONE