Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-02-08 13:14:26 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-02-08 13:14:26 +0300
commit345c6298e995ea618c34282ba6d7ab5af032f191 (patch)
treef4fbc4798e17d0f19efc28b51a41425d0c552be8 /source/blender/editors/util
parent14a19fed788af0cf3695eb5def92510841056e08 (diff)
Object Mode: move to workspace struct
- Read-only access can often use EvaluationContext.object_mode - Write access to go to WorkSpace.object_mode. - Some TODO's remain (marked as "TODO/OBMODE") - Add-ons will need updating (context.active_object.mode -> context.workspace.object_mode) - There will be small/medium issues that still need resolving this does work on a basic level though. See D3037
Diffstat (limited to 'source/blender/editors/util')
-rw-r--r--source/blender/editors/util/ed_util.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 8973c96c438..02443af0bfc 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -41,6 +41,7 @@
#include "DNA_space_types.h"
#include "DNA_scene_types.h"
#include "DNA_packedFile_types.h"
+#include "DNA_workspace_types.h"
#include "BLI_utildefines.h"
#include "BLI_string.h"
@@ -70,6 +71,8 @@
#include "ED_space_api.h"
#include "ED_util.h"
+#include "DEG_depsgraph.h"
+
#include "GPU_immediate.h"
#include "UI_interface.h"
@@ -86,11 +89,7 @@
void ED_editors_init(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
- Main *bmain = CTX_data_main(C);
Scene *sce = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- Object *ob, *obact = (view_layer && view_layer->basact) ? view_layer->basact->object : NULL;
- ID *data;
/* This is called during initialization, so we don't want to store any reports */
ReportList *reports = CTX_wm_reports(C);
@@ -98,24 +97,6 @@ void ED_editors_init(bContext *C)
SWAP(int, reports->flag, reports_flag_prev);
- /* toggle on modes for objects that were saved with these enabled. for
- * e.g. linked objects we have to ensure that they are actually the
- * active object in this scene. */
- for (ob = bmain->object.first; ob; ob = ob->id.next) {
- int mode = ob->mode;
-
- if (mode == OB_MODE_OBJECT) {
- /* pass */
- }
- else {
- data = ob->data;
- ob->mode = OB_MODE_OBJECT;
- if ((ob == obact) && !ID_IS_LINKED(ob) && !(data && ID_IS_LINKED(data))) {
- ED_object_toggle_modes(C, mode);
- }
- }
- }
-
/* image editor paint mode */
if (sce) {
ED_space_image_paint_update(wm, sce);
@@ -170,11 +151,16 @@ bool ED_editors_flush_edits(const bContext *C, bool for_render)
Object *ob;
Main *bmain = CTX_data_main(C);
+ eObjectMode object_mode = WM_windows_object_mode_get(bmain->wm.first);
+ if ((object_mode & (OB_MODE_SCULPT | OB_MODE_EDIT)) == 0) {
+ return has_edited;
+ }
+
/* 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->object.first; ob; ob = ob->id.next) {
- if (ob->mode & OB_MODE_SCULPT) {
+ if (object_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) {
@@ -193,7 +179,7 @@ bool ED_editors_flush_edits(const bContext *C, bool for_render)
}
}
}
- else if (ob->mode & OB_MODE_EDIT) {
+ else if (object_mode & OB_MODE_EDIT) {
/* get editmode results */
has_edited = true;
ED_object_editmode_load(ob);