diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-01-15 13:25:22 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-01-15 13:36:50 +0300 |
commit | e375685e06d0b4c52a0aacb8982684e45b490d5c (patch) | |
tree | 99f832891b05d72af98b4fe68ef0b10187da8332 /source | |
parent | 01029c68d293593ccf5019793a5b577b3b522338 (diff) |
Cleanup: pass main instead of context w/ ED_editors_exit/flush_edits
Useful for calling from lower level code.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/include/ED_util.h | 13 | ||||
-rw-r--r-- | source/blender/editors/render/render_internal.c | 2 | ||||
-rw-r--r-- | source/blender/editors/scene/scene_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/util/ed_util.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 11 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 11 |
6 files changed, 27 insertions, 25 deletions
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h index 7e91b5b88c1..05131d103fc 100644 --- a/source/blender/editors/include/ED_util.h +++ b/source/blender/editors/include/ED_util.h @@ -35,17 +35,16 @@ struct bContext; struct wmOperatorType; +struct Main; /* ed_util.c */ +void ED_editors_init(struct bContext *C); +void ED_editors_exit(struct Main *bmain); +bool ED_editors_flush_edits(struct Main *bmain, bool for_render); -void ED_editors_init(struct bContext *C); -void ED_editors_exit(struct bContext *C); +void ED_spacedata_id_remap(struct ScrArea *sa, struct SpaceLink *sl, struct ID *old_id, struct ID *new_id); -bool ED_editors_flush_edits(const struct bContext *C, bool for_render); - -void ED_spacedata_id_remap(struct ScrArea *sa, struct SpaceLink *sl, struct ID *old_id, struct ID *new_id); - -void ED_OT_flush_edits(struct wmOperatorType *ot); +void ED_OT_flush_edits(struct wmOperatorType *ot); /* ************** XXX OLD CRUFT WARNING ************* */ diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 1ca06beefad..09596ed7b16 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -896,7 +896,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even WM_cursor_wait(1); /* flush sculpt and editmode changes */ - ED_editors_flush_edits(C, true); + ED_editors_flush_edits(bmain, true); /* cleanup sequencer caches before starting user triggered render. * otherwise, invalidated cache entries can make their way into diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c index 1755b143e24..60f16835cf3 100644 --- a/source/blender/editors/scene/scene_edit.c +++ b/source/blender/editors/scene/scene_edit.c @@ -78,7 +78,7 @@ Scene *ED_scene_add(Main *bmain, bContext *C, wmWindow *win, eSceneCopyMethod me ED_object_single_users(bmain, scene_new, false, true); } else if (method == SCE_COPY_FULL) { - ED_editors_flush_edits(C, false); + ED_editors_flush_edits(bmain, false); ED_object_single_users(bmain, scene_new, true, true); } } diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 188d06cec55..30021d6a0c9 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -157,12 +157,11 @@ void ED_editors_init(bContext *C) } /* frees all editmode stuff */ -void ED_editors_exit(bContext *C) +void ED_editors_exit(Main *bmain) { - Main *bmain = CTX_data_main(C); - - if (!bmain) + if (!bmain) { return; + } /* frees all editmode undos */ if (G_MAIN->wm.first) { @@ -198,11 +197,10 @@ void ED_editors_exit(bContext *C) /* flush any temp data from object editing to DNA before writing files, * rendering, copying, etc. */ -bool ED_editors_flush_edits(const bContext *C, bool for_render) +bool ED_editors_flush_edits(Main *bmain, bool for_render) { bool has_edited = false; Object *ob; - Main *bmain = CTX_data_main(C); /* loop through all data to find edit mode or object mode, because during * exiting we might not have a context for edit object and multiple sculpt @@ -400,7 +398,8 @@ void ED_spacedata_id_remap(struct ScrArea *sa, struct SpaceLink *sl, ID *old_id, static int ed_flush_edits_exec(bContext *C, wmOperator *UNUSED(op)) { - ED_editors_flush_edits(C, false); + Main *bmain = CTX_data_main(C); + ED_editors_flush_edits(bmain, false); return OPERATOR_FINISHED; } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index beb963a2af3..379bd56a9c2 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -184,7 +184,7 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist) * (see T47632), so for now just handling this specific case here. */ CTX_wm_menu_set(C, NULL); - ED_editors_exit(C); + ED_editors_exit(G_MAIN); } static void wm_window_substitute_old(wmWindowManager *oldwm, wmWindowManager *wm, wmWindow *oldwin, wmWindow *win) @@ -1296,7 +1296,7 @@ static bool wm_file_write(bContext *C, const char *filepath, int fileflags, Repo /* don't forget not to return without! */ WM_cursor_wait(1); - ED_editors_flush_edits(C, false); + ED_editors_flush_edits(bmain, false); fileflags |= G_FILE_HISTORY; /* write file history */ @@ -1428,12 +1428,13 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w } else { /* save as regular blend file */ + Main *bmain = CTX_data_main(C); int fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY); - ED_editors_flush_edits(C, false); + ED_editors_flush_edits(bmain, false); /* Error reporting into console */ - BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL); + BLO_write_file(bmain, filepath, fileflags, NULL, NULL); } /* do timer after file write, just in case file write takes a long time */ wm->autosavetimer = WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, U.savetime * 60.0); @@ -1554,7 +1555,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op) printf("Writing homefile: '%s' ", filepath); - ED_editors_flush_edits(C, false); + ED_editors_flush_edits(bmain, false); /* force save as regular blend file */ fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index e4ae9495c61..e3587c2c965 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -440,15 +440,16 @@ void WM_exit_ext(bContext *C, const bool do_python) struct MemFile *undo_memfile = wm->undo_stack ? ED_undosys_stack_memfile_get_active(wm->undo_stack) : NULL; if ((U.uiflag2 & USER_KEEP_SESSION) || (undo_memfile != NULL)) { /* save the undo state as quit.blend */ + Main *bmain = CTX_data_main(C); char filename[FILE_MAX]; bool has_edited; int fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY); BLI_make_file_string("/", filename, BKE_tempdir_base(), BLENDER_QUIT_FILE); - has_edited = ED_editors_flush_edits(C, false); + has_edited = ED_editors_flush_edits(bmain, false); - if ((has_edited && BLO_write_file(CTX_data_main(C), filename, fileflags, NULL, NULL)) || + if ((has_edited && BLO_write_file(bmain, filename, fileflags, NULL, NULL)) || (undo_memfile && BLO_memfile_write_file(undo_memfile, filename))) { printf("Saved session recovery to '%s'\n", filename); @@ -480,8 +481,10 @@ void WM_exit_ext(bContext *C, const bool do_python) WM_uilisttype_free(); /* all non-screen and non-space stuff editors did, like editmode */ - if (C) - ED_editors_exit(C); + if (C) { + Main *bmain = CTX_data_main(C); + ED_editors_exit(bmain); + } ED_undosys_type_free(); |