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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user