[Bf-blender-cvs] [de994d6b7b1] blender2.8: GP: Fix problem with mode opening 2D Animation template

Antonioya noreply at git.blender.org
Thu Sep 20 13:48:07 CEST 2018


Commit: de994d6b7b1c8789ee2797b8138c2fb115370b9c
Author: Antonioya
Date:   Thu Sep 20 13:47:59 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBde994d6b7b1c8789ee2797b8138c2fb115370b9c

GP: Fix problem with mode opening 2D Animation template

The grease pencil does not need a toggle of mode.

This fix also the problem when open grease pencil files that did not keep the mode saved.

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

M	source/blender/blenkernel/intern/object.c
M	source/blender/blenloader/intern/versioning_defaults.c
M	source/blender/editors/util/ed_util.c

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

diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 8864a613761..c09630f5f75 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1296,7 +1296,7 @@ void BKE_object_copy_data(Main *bmain, Object *ob_dst, const Object *ob_src, con
 	BKE_object_facemap_copy_list(&ob_dst->fmaps, &ob_src->fmaps);
 	BKE_constraints_copy_ex(&ob_dst->constraints, &ob_src->constraints, flag_subdata, true);
 
-	ob_dst->mode = OB_MODE_OBJECT;
+	ob_dst->mode = ob_dst->type != OB_GPENCIL ? OB_MODE_OBJECT : ob_dst->mode;
 	ob_dst->sculpt = NULL;
 
 	if (ob_src->pd) {
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index e6a5d20f017..8972e7ef56f 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -32,6 +32,7 @@
 #include "BLI_math.h"
 #include "BLI_string.h"
 
+#include "DNA_gpencil_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
@@ -102,6 +103,16 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
 				workspace->object_mode = OB_MODE_GPENCIL_PAINT;
 			}
 		}
+		/* set object in drawing mode */
+		for (Object *object = bmain->object.first; object; object = object->id.next) {
+			if (object->type == OB_GPENCIL) {
+				bGPdata *gpd = (bGPdata *)object->data;
+				object->mode = OB_MODE_GPENCIL_PAINT;
+				gpd->flag |= GP_DATA_STROKE_PAINTMODE;
+				break;
+			}
+		}
+
 		/* Be sure curfalloff is initializated */
 		for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
 			ToolSettings *ts = scene->toolsettings;
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 30c1606e3d8..10698b9ebab 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -115,11 +115,15 @@ void ED_editors_init(bContext *C)
 				/* pass */
 			}
 			else if (!BKE_object_has_mode_data(ob, mode)) {
-				/* For multi-edit mode we may already have mode data. */
-				ID *data = ob->data;
-				ob->mode = OB_MODE_OBJECT;
-				if ((ob == obact) && !ID_IS_LINKED(ob) && !(data && ID_IS_LINKED(data))) {
-					ED_object_mode_toggle(C, mode);
+				/* For multi-edit mode we may already have mode data.
+				 * (grease pencil does not need it)
+				 */
+				if (ob->type != OB_GPENCIL) {
+					ID *data = ob->data;
+					ob->mode = OB_MODE_OBJECT;
+					if ((ob == obact) && !ID_IS_LINKED(ob) && !(data && ID_IS_LINKED(data))) {
+						ED_object_mode_toggle(C, mode);
+					}
 				}
 			}
 		}



More information about the Bf-blender-cvs mailing list