Cleanup: pass main instead of context w/ ED_editors_exit/flush_edits
Useful for calling from lower level code.
This commit is contained in:
parent
01029c68d2
commit
e375685e06
@ -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 ************* */
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user