Cleanup: ED_editors_flush_* functions
- Remove the only_render arg from ED_editors_flush_edits was only used in one place, the '_ex' version can be used instead. - Split out the single object version of this function as currently flushing is being done in-line, often only accounting for edit-mode, ignoring sculpt mode for e.g.
This commit is contained in:
@@ -35,8 +35,14 @@ void ED_editors_init_for_undo(struct Main *bmain);
|
|||||||
void ED_editors_init(struct bContext *C);
|
void ED_editors_init(struct bContext *C);
|
||||||
void ED_editors_exit(struct Main *bmain, bool do_undo_system);
|
void ED_editors_exit(struct Main *bmain, bool do_undo_system);
|
||||||
|
|
||||||
|
bool ED_editors_flush_edits_for_object_ex(struct Main *bmain,
|
||||||
|
struct Object *ob,
|
||||||
|
bool for_render,
|
||||||
|
bool check_needs_flush);
|
||||||
|
bool ED_editors_flush_edits_for_object(struct Main *bmain, struct Object *ob);
|
||||||
|
|
||||||
bool ED_editors_flush_edits_ex(struct Main *bmain, bool for_render, bool check_needs_flush);
|
bool ED_editors_flush_edits_ex(struct Main *bmain, bool for_render, bool check_needs_flush);
|
||||||
bool ED_editors_flush_edits(struct Main *bmain, bool for_render);
|
bool ED_editors_flush_edits(struct Main *bmain);
|
||||||
|
|
||||||
void ED_spacedata_id_remap(struct ScrArea *sa,
|
void ED_spacedata_id_remap(struct ScrArea *sa,
|
||||||
struct SpaceLink *sl,
|
struct SpaceLink *sl,
|
||||||
|
@@ -955,7 +955,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
|||||||
WM_cursor_wait(1);
|
WM_cursor_wait(1);
|
||||||
|
|
||||||
/* flush sculpt and editmode changes */
|
/* flush sculpt and editmode changes */
|
||||||
ED_editors_flush_edits(bmain, true);
|
ED_editors_flush_edits_ex(bmain, true, false);
|
||||||
|
|
||||||
/* cleanup sequencer caches before starting user triggered render.
|
/* cleanup sequencer caches before starting user triggered render.
|
||||||
* otherwise, invalidated cache entries can make their way into
|
* otherwise, invalidated cache entries can make their way into
|
||||||
|
@@ -65,7 +65,7 @@ Scene *ED_scene_add(Main *bmain, bContext *C, wmWindow *win, eSceneCopyMethod me
|
|||||||
|
|
||||||
/* these can't be handled in blenkernel currently, so do them here */
|
/* these can't be handled in blenkernel currently, so do them here */
|
||||||
if (method == SCE_COPY_FULL) {
|
if (method == SCE_COPY_FULL) {
|
||||||
ED_editors_flush_edits(bmain, false);
|
ED_editors_flush_edits(bmain);
|
||||||
ED_object_single_users(bmain, scene_new, true, true);
|
ED_object_single_users(bmain, scene_new, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -228,17 +228,12 @@ void ED_editors_exit(Main *bmain, bool do_undo_system)
|
|||||||
ED_mesh_mirror_topo_table(NULL, NULL, 'e');
|
ED_mesh_mirror_topo_table(NULL, NULL, 'e');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* flush any temp data from object editing to DNA before writing files,
|
bool ED_editors_flush_edits_for_object_ex(Main *bmain,
|
||||||
* rendering, copying, etc. */
|
Object *ob,
|
||||||
bool ED_editors_flush_edits_ex(Main *bmain, bool for_render, bool check_needs_flush)
|
bool for_render,
|
||||||
|
bool check_needs_flush)
|
||||||
{
|
{
|
||||||
bool has_edited = false;
|
bool has_edited = false;
|
||||||
Object *ob;
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
* objects can exist at the same time */
|
|
||||||
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
|
|
||||||
if (ob->mode & OB_MODE_SCULPT) {
|
if (ob->mode & OB_MODE_SCULPT) {
|
||||||
/* Don't allow flushing while in the middle of a stroke (frees data in use).
|
/* Don't allow flushing while in the middle of a stroke (frees data in use).
|
||||||
* Auto-save prevents this from happening but scripts
|
* Auto-save prevents this from happening but scripts
|
||||||
@@ -248,7 +243,7 @@ bool ED_editors_flush_edits_ex(Main *bmain, bool for_render, bool check_needs_fl
|
|||||||
{
|
{
|
||||||
char *needs_flush_ptr = &ob->sculpt->needs_flush_to_id;
|
char *needs_flush_ptr = &ob->sculpt->needs_flush_to_id;
|
||||||
if (check_needs_flush && (*needs_flush_ptr == 0)) {
|
if (check_needs_flush && (*needs_flush_ptr == 0)) {
|
||||||
continue;
|
return false;
|
||||||
}
|
}
|
||||||
*needs_flush_ptr = 0;
|
*needs_flush_ptr = 0;
|
||||||
}
|
}
|
||||||
@@ -273,7 +268,7 @@ bool ED_editors_flush_edits_ex(Main *bmain, bool for_render, bool check_needs_fl
|
|||||||
char *needs_flush_ptr = BKE_object_data_editmode_flush_ptr_get(ob->data);
|
char *needs_flush_ptr = BKE_object_data_editmode_flush_ptr_get(ob->data);
|
||||||
if (needs_flush_ptr != NULL) {
|
if (needs_flush_ptr != NULL) {
|
||||||
if (check_needs_flush && (*needs_flush_ptr == 0)) {
|
if (check_needs_flush && (*needs_flush_ptr == 0)) {
|
||||||
continue;
|
return false;
|
||||||
}
|
}
|
||||||
*needs_flush_ptr = 0;
|
*needs_flush_ptr = 0;
|
||||||
}
|
}
|
||||||
@@ -282,6 +277,26 @@ bool ED_editors_flush_edits_ex(Main *bmain, bool for_render, bool check_needs_fl
|
|||||||
has_edited = true;
|
has_edited = true;
|
||||||
ED_object_editmode_load(bmain, ob);
|
ED_object_editmode_load(bmain, ob);
|
||||||
}
|
}
|
||||||
|
return has_edited;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ED_editors_flush_edits_for_object(Main *bmain, Object *ob)
|
||||||
|
{
|
||||||
|
return ED_editors_flush_edits_for_object_ex(bmain, ob, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* flush any temp data from object editing to DNA before writing files,
|
||||||
|
* rendering, copying, etc. */
|
||||||
|
bool ED_editors_flush_edits_ex(Main *bmain, bool for_render, bool check_needs_flush)
|
||||||
|
{
|
||||||
|
bool has_edited = false;
|
||||||
|
Object *ob;
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
* objects can exist at the same time */
|
||||||
|
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
|
||||||
|
has_edited |= ED_editors_flush_edits_for_object_ex(bmain, ob, for_render, check_needs_flush);
|
||||||
}
|
}
|
||||||
|
|
||||||
bmain->is_memfile_undo_flush_needed = false;
|
bmain->is_memfile_undo_flush_needed = false;
|
||||||
@@ -289,9 +304,9 @@ bool ED_editors_flush_edits_ex(Main *bmain, bool for_render, bool check_needs_fl
|
|||||||
return has_edited;
|
return has_edited;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ED_editors_flush_edits(Main *bmain, bool for_render)
|
bool ED_editors_flush_edits(Main *bmain)
|
||||||
{
|
{
|
||||||
return ED_editors_flush_edits_ex(bmain, for_render, false);
|
return ED_editors_flush_edits_ex(bmain, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ***** XXX: functions are using old blender names, cleanup later ***** */
|
/* ***** XXX: functions are using old blender names, cleanup later ***** */
|
||||||
@@ -472,7 +487,7 @@ 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))
|
static int ed_flush_edits_exec(bContext *C, wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
ED_editors_flush_edits(bmain, false);
|
ED_editors_flush_edits(bmain);
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1386,7 +1386,7 @@ static bool wm_file_write(bContext *C, const char *filepath, int fileflags, Repo
|
|||||||
/* don't forget not to return without! */
|
/* don't forget not to return without! */
|
||||||
WM_cursor_wait(1);
|
WM_cursor_wait(1);
|
||||||
|
|
||||||
ED_editors_flush_edits(bmain, false);
|
ED_editors_flush_edits(bmain);
|
||||||
|
|
||||||
fileflags |= G_FILE_HISTORY; /* write file history */
|
fileflags |= G_FILE_HISTORY; /* write file history */
|
||||||
|
|
||||||
@@ -1527,7 +1527,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w
|
|||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
int fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY);
|
int fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY);
|
||||||
|
|
||||||
ED_editors_flush_edits(bmain, false);
|
ED_editors_flush_edits(bmain);
|
||||||
|
|
||||||
/* Error reporting into console */
|
/* Error reporting into console */
|
||||||
BLO_write_file(bmain, filepath, fileflags, NULL, NULL);
|
BLO_write_file(bmain, filepath, fileflags, NULL, NULL);
|
||||||
@@ -1655,7 +1655,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
printf("Writing homefile: '%s' ", filepath);
|
printf("Writing homefile: '%s' ", filepath);
|
||||||
|
|
||||||
ED_editors_flush_edits(bmain, false);
|
ED_editors_flush_edits(bmain);
|
||||||
|
|
||||||
/* force save as regular blend file */
|
/* force save as regular blend file */
|
||||||
fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY);
|
fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY);
|
||||||
|
@@ -499,7 +499,7 @@ void WM_exit_ex(bContext *C, const bool do_python)
|
|||||||
|
|
||||||
BLI_make_file_string("/", filename, BKE_tempdir_base(), BLENDER_QUIT_FILE);
|
BLI_make_file_string("/", filename, BKE_tempdir_base(), BLENDER_QUIT_FILE);
|
||||||
|
|
||||||
has_edited = ED_editors_flush_edits(bmain, false);
|
has_edited = ED_editors_flush_edits(bmain);
|
||||||
|
|
||||||
if ((has_edited && BLO_write_file(bmain, filename, fileflags, NULL, NULL)) ||
|
if ((has_edited && BLO_write_file(bmain, filename, fileflags, NULL, NULL)) ||
|
||||||
(undo_memfile && BLO_memfile_write_file(undo_memfile, filename))) {
|
(undo_memfile && BLO_memfile_write_file(undo_memfile, filename))) {
|
||||||
|
Reference in New Issue
Block a user