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-22 07:52:30 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-02-22 07:52:30 +0300
commit026ac65831f340c4517903d2b7a377a957b55c0a (patch)
treede6711ec7116a57f46accf7b0f340ea556a4297f /source/blender/editors/util
parent648df0fcdb8249d8d00ee501d6947216bb7330d5 (diff)
WorkSpace: Restore saved object-modes again
Was temporarily removed when moving object mode to workspace. Note: there is an issue where eval_ctx->view_layer is NULL on load, for now pass a view layer argument, we might wan't to set the value instead.
Diffstat (limited to 'source/blender/editors/util')
-rw-r--r--source/blender/editors/util/ed_util.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index a5a26cf4d57..562ba2c42b3 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -60,6 +60,8 @@
#include "BKE_packedFile.h"
#include "BKE_paint.h"
#include "BKE_screen.h"
+#include "BKE_workspace.h"
+#include "BKE_layer.h"
#include "ED_armature.h"
#include "ED_buttons.h"
@@ -90,7 +92,6 @@
void ED_editors_init(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
- Scene *sce = CTX_data_scene(C);
/* This is called during initialization, so we don't want to store any reports */
ReportList *reports = CTX_wm_reports(C);
@@ -98,9 +99,45 @@ 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. */
+ {
+ wmWindow *win_orig = CTX_wm_window(C);
+ CTX_wm_window_set(C, NULL);
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ WorkSpace *workspace = WM_window_get_active_workspace(win);
+ Scene *scene = WM_window_get_active_scene(win);
+ ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace);
+ Object *obact = view_layer ? OBACT(view_layer) : NULL;
+ eObjectMode object_mode = workspace->object_mode;
+ workspace->object_mode = OB_MODE_OBJECT;
+ if (view_layer && obact) {
+ const ID *data = obact->data;
+ if (!ELEM(object_mode, OB_MODE_OBJECT, OB_MODE_POSE)) {
+ if (!ID_IS_LINKED(obact) && !(data && ID_IS_LINKED(data))) {
+ CTX_wm_window_set(C, win);
+ ED_object_toggle_modes(C, object_mode);
+ CTX_wm_window_set(C, NULL);
+ }
+ }
+ else if (object_mode == OB_MODE_POSE) {
+ if (!ID_IS_LINKED(obact) && (obact->type == OB_ARMATURE)) {
+ workspace->object_mode = object_mode;
+ }
+ }
+ }
+ }
+ CTX_wm_window_set(C, win_orig);
+ }
+
/* image editor paint mode */
- if (sce) {
- ED_space_image_paint_update(wm, sce);
+ {
+ Scene *sce = CTX_data_scene(C);
+ if (sce) {
+ ED_space_image_paint_update(wm, sce);
+ }
}
SWAP(int, reports->flag, reports_flag_prev);