diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-01-30 08:52:36 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-01-30 08:52:36 +0300 |
commit | d83acac66bea749584144affa1d82461ac238f6d (patch) | |
tree | 172965b22c4adeedbe9304ef8d6686ee11ed66fe /source/blender/editors | |
parent | 97ace45e42ad3d5633c5b076b61c6ed9b5494f97 (diff) | |
parent | 725477fdb163d7782d75747faaef09afba79e751 (diff) |
Merge branch 'blender-v2.82-release'
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_util.h | 8 | ||||
-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/space_outliner/outliner_tools.c | 5 | ||||
-rw-r--r-- | source/blender/editors/util/ed_util.c | 107 |
5 files changed, 73 insertions, 51 deletions
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h index 003e84bbf05..8cce8fa973a 100644 --- a/source/blender/editors/include/ED_util.h +++ b/source/blender/editors/include/ED_util.h @@ -35,8 +35,14 @@ void ED_editors_init_for_undo(struct Main *bmain); void ED_editors_init(struct bContext *C); 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(struct Main *bmain, bool for_render); +bool ED_editors_flush_edits(struct Main *bmain); void ED_spacedata_id_remap(struct ScrArea *sa, struct SpaceLink *sl, diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 5740dacd05f..11821fcdc45 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -955,7 +955,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(bmain, true); + ED_editors_flush_edits_ex(bmain, true, false); /* 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 7705278443f..22c91686bbf 100644 --- a/source/blender/editors/scene/scene_edit.c +++ b/source/blender/editors/scene/scene_edit.c @@ -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 */ 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); } } diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 234da323de6..c9eeb2cff20 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -46,6 +46,7 @@ #include "BKE_collection.h" #include "BKE_context.h" #include "BKE_constraint.h" +#include "BKE_object.h" #include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_layer.h" @@ -678,8 +679,8 @@ static void object_delete_cb(bContext *C, } // check also library later - if (ob == CTX_data_edit_object(C)) { - ED_object_editmode_exit(C, EM_FREEDATA); + if ((ob->mode && OB_MODE_EDIT) && BKE_object_is_in_editmode(ob)) { + ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA); } BKE_id_delete(bmain, ob); } diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 1a33b50ff10..b4b89c31414 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -228,6 +228,63 @@ void ED_editors_exit(Main *bmain, bool do_undo_system) ED_mesh_mirror_topo_table(NULL, NULL, 'e'); } +bool ED_editors_flush_edits_for_object_ex(Main *bmain, + Object *ob, + bool for_render, + bool check_needs_flush) +{ + bool has_edited = false; + if (ob->mode & OB_MODE_SCULPT) { + /* Don't allow flushing while in the middle of a stroke (frees data in use). + * Auto-save prevents this from happening but scripts + * may cause a flush on saving: T53986. */ + if ((ob->sculpt && ob->sculpt->cache) == 0) { + + { + char *needs_flush_ptr = &ob->sculpt->needs_flush_to_id; + if (check_needs_flush && (*needs_flush_ptr == 0)) { + return false; + } + *needs_flush_ptr = 0; + } + + /* flush multires changes (for sculpt) */ + multires_flush_sculpt_updates(ob); + has_edited = true; + + if (for_render) { + /* flush changes from dynamic topology sculpt */ + BKE_sculptsession_bm_to_me_for_render(ob); + } + else { + /* Set reorder=false so that saving the file doesn't reorder + * the BMesh's elements */ + BKE_sculptsession_bm_to_me(ob, false); + } + } + } + else if (ob->mode & OB_MODE_EDIT) { + + char *needs_flush_ptr = BKE_object_data_editmode_flush_ptr_get(ob->data); + if (needs_flush_ptr != NULL) { + if (check_needs_flush && (*needs_flush_ptr == 0)) { + return false; + } + *needs_flush_ptr = 0; + } + + /* get editmode results */ + has_edited = true; + 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) @@ -239,49 +296,7 @@ bool ED_editors_flush_edits_ex(Main *bmain, bool for_render, bool check_needs_fl * 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) { - /* Don't allow flushing while in the middle of a stroke (frees data in use). - * Auto-save prevents this from happening but scripts - * may cause a flush on saving: T53986. */ - if ((ob->sculpt && ob->sculpt->cache) == 0) { - - { - char *needs_flush_ptr = &ob->sculpt->needs_flush_to_id; - if (check_needs_flush && (*needs_flush_ptr == 0)) { - continue; - } - *needs_flush_ptr = 0; - } - - /* flush multires changes (for sculpt) */ - multires_flush_sculpt_updates(ob); - has_edited = true; - - if (for_render) { - /* flush changes from dynamic topology sculpt */ - BKE_sculptsession_bm_to_me_for_render(ob); - } - else { - /* Set reorder=false so that saving the file doesn't reorder - * the BMesh's elements */ - BKE_sculptsession_bm_to_me(ob, false); - } - } - } - else if (ob->mode & OB_MODE_EDIT) { - - char *needs_flush_ptr = BKE_object_data_editmode_flush_ptr_get(ob->data); - if (needs_flush_ptr != NULL) { - if (check_needs_flush && (*needs_flush_ptr == 0)) { - continue; - } - *needs_flush_ptr = 0; - } - - /* get editmode results */ - has_edited = true; - ED_object_editmode_load(bmain, ob); - } + has_edited |= ED_editors_flush_edits_for_object_ex(bmain, ob, for_render, check_needs_flush); } 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; } -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 ***** */ @@ -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)) { Main *bmain = CTX_data_main(C); - ED_editors_flush_edits(bmain, false); + ED_editors_flush_edits(bmain); return OPERATOR_FINISHED; } |