Commit: b95b48f149d1dbeaa6596714a68129e465a8d2b7
Author: Joshua Leung
Date:   Mon Oct 30 00:10:40 2017 +1300
Branches: greasepencil-object
https://developer.blender.org/rBb95b48f149d1dbeaa6596714a68129e465a8d2b7

Fix: GP objects should get created with GP datablocks initialised already
(just like all other object types)

Previously, because the GP datablock was stored in a different place,
this had to be handled differently from other datablocks. But that
doesn't hold anymore, so it's time to fix that.

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

M       source/blender/blenkernel/intern/object.c
M       source/blender/editors/object/object_add.c

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

diff --git a/source/blender/blenkernel/intern/object.c 
b/source/blender/blenkernel/intern/object.c
index f16fe6edb9f..0809a336123 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -611,7 +611,7 @@ static const char *get_obdata_defname(int type)
                case OB_ARMATURE: return DATA_("Armature");
                case OB_SPEAKER: return DATA_("Speaker");
                case OB_EMPTY: return DATA_("Empty");
-               case OB_GPENCIL: return DATA_("Gpencil");
+               case OB_GPENCIL: return DATA_("GPencil");
                default:
                        printf("get_obdata_defname: Internal error, bad type: 
%d\n", type);
                        return DATA_("Empty");
@@ -636,8 +636,8 @@ void *BKE_object_obdata_add_from_type(Main *bmain, int 
type, const char *name)
                case OB_ARMATURE:  return BKE_armature_add(bmain, name);
                case OB_SPEAKER:   return BKE_speaker_add(bmain, name);
                case OB_LIGHTPROBE:return BKE_lightprobe_add(bmain, name);
+               case OB_GPENCIL:   return BKE_gpencil_data_addnew(bmain, name);
                case OB_EMPTY:     return NULL;
-               case OB_GPENCIL:   return NULL;
                default:
                        printf("%s: Internal error, bad type: %d\n", __func__, 
type);
                        return NULL;
diff --git a/source/blender/editors/object/object_add.c 
b/source/blender/editors/object/object_add.c
index cd0dc51838b..0d695d7d18e 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1014,9 +1014,6 @@ static int object_gpencil_add_exec(bContext *C, 
wmOperator *op)
        /* set grease pencil mode to object */
        ToolSettings *ts = CTX_data_tool_settings(C);
        ts->gpencil_src = GP_TOOL_SOURCE_OBJECT;
-       /* add a grease pencil datablock */     
-       // XXX: This initialisation should be handled when initialising the 
object...
-       ob->data = BKE_gpencil_data_addnew(CTX_data_main(C), DATA_("GPencil"));
        
        /* if type is monkey, create a 2D Suzanne */
        // TODO: create with offset to cursor?

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to