[Bf-blender-cvs] [e9150ac3176] blender-v3.1-release: Fix T89514: GP draw mode not saved when scene is not the active one

Falk David noreply at git.blender.org
Tue Feb 1 16:08:17 CET 2022


Commit: e9150ac3176eb46e90afa8fd62b33818e59b8de7
Author: Falk David
Date:   Tue Feb 1 15:58:12 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rBe9150ac3176eb46e90afa8fd62b33818e59b8de7

Fix T89514: GP draw mode not saved when scene is not the active one

This patch fixes the error that pops up
(`Error: Unable to execute '... Mode Toggle', error changing modes`)
when trying to switch to e.g. draw mode from a grease pencil object
that was saved in draw mode in an inactive scene when the file was loaded.

Note that this does not fix the bigger issue described in T91243.

The fix makes sure that we reset all the mode flags on the grease pencil
data when we set the mode to object mode.

Reviewed By: antoniov

Maniphest Tasks: T89514

Differential Revision: https://developer.blender.org/D12419

===================================================================

M	source/blender/editors/util/ed_util.c

===================================================================

diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 0320a2a9a1a..e86392e47ab 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -47,6 +47,8 @@
 
 #include "DEG_depsgraph.h"
 
+#include "DNA_gpencil_types.h"
+
 #include "ED_armature.h"
 #include "ED_asset.h"
 #include "ED_image.h"
@@ -117,6 +119,10 @@ void ED_editors_init(bContext *C)
       /* For multi-edit mode we may already have mode data (grease pencil does not need it).
        * However we may have a non-active object stuck in a grease-pencil edit mode. */
       if (ob != obact) {
+        bGPdata *gpd = (bGPdata *)ob->data;
+        gpd->flag &= ~(GP_DATA_STROKE_PAINTMODE | GP_DATA_STROKE_EDITMODE |
+                       GP_DATA_STROKE_SCULPTMODE | GP_DATA_STROKE_WEIGHTMODE |
+                       GP_DATA_STROKE_VERTEXMODE);
         ob->mode = OB_MODE_OBJECT;
         DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
       }



More information about the Bf-blender-cvs mailing list