diff options
author | Antonioya <blendergit@gmail.com> | 2019-03-12 21:58:43 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2019-03-12 21:58:43 +0300 |
commit | 480ee612de0afd3a1cf1fc23534e008ad9855a40 (patch) | |
tree | 2ed30e438e13dca838829b00f2fd6fb4f702fe0b /source/blender/editors/gpencil/gpencil_data.c | |
parent | 6eaaa9c3d313358428832e26c8d62ade3ea96568 (diff) |
GPencil: Restrict new data operator to object mode
The operator was only accessible from search menu, and this was wrong. The operator must be only used in object mode.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_data.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_data.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index cfcfc49b081..02473329f03 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -89,6 +89,18 @@ /* Datablock Operators */ /* ******************* Add New Data ************************ */ +bool gp_data_add_poll(bContext *C) +{ + Object *obact = CTX_data_active_object(C); + if (obact && obact->type == OB_GPENCIL) { + if (obact->mode != OB_MODE_OBJECT) { + return false; + } + } + + /* the base line we have is that we have somewhere to add Grease Pencil data */ + return ED_gpencil_data_get_pointers(C, NULL) != NULL; +} /* add new datablock - wrapper around API */ static int gp_data_add_exec(bContext *C, wmOperator *op) @@ -153,7 +165,7 @@ void GPENCIL_OT_data_add(wmOperatorType *ot) /* callbacks */ ot->exec = gp_data_add_exec; - ot->poll = gp_add_poll; + ot->poll = gp_data_add_poll; } /* ******************* Unlink Data ************************ */ |