diff options
author | Joshua Leung <aligorith@gmail.com> | 2015-01-19 06:38:32 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2015-01-19 09:11:18 +0300 |
commit | 32ffc63d20908c6433e0e92488be3b5568f81f69 (patch) | |
tree | 78eff17a0e82a1d7ef1bafafe5f54cb09ca1f187 /source/blender/editors/gpencil/gpencil_utils.c | |
parent | 0a128af21d6d06ddeb1acbccacda1fdde1843fd0 (diff) |
Bugfix T43293: Crash when editing shared GPencil datablock in VSE
The problem here was that when a Grease Pencil datablock is shared between
the 3D view and another one of the editors, all the strokes were getting handled
by the editing operators, even if those strokes could not be displayed/used
in that context. As a result, the coordinate conversion methods would fail,
as some of the needed data would not be set.
The fix here involves not including any offending strokes in such cases...
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_utils.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index c7218e8e5ff..289cbc568d2 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -90,6 +90,42 @@ bool gp_stroke_inside_circle(const int mval[2], const int UNUSED(mvalo[2]), /* ******************************************************** */ +/* Check whether given stroke can be edited given the supplied context */ +// XXX: do we need additional flags for screenspace vs dataspace? +bool ED_gpencil_stroke_can_use_direct(const ScrArea *sa, const bGPDstroke *gps) +{ + /* sanity check */ + if (ELEM(NULL, sa, gps)) + return false; + + /* filter stroke types by flags + spacetype */ + if (gps->flag & GP_STROKE_3DSPACE) { + /* 3D strokes - only in 3D view */ + return (sa->spacetype == SPACE_VIEW3D); + } + else if (gps->flag & GP_STROKE_2DIMAGE) { + /* Special "image" strokes - only in Image Editor */ + return (sa->spacetype == SPACE_IMAGE); + } + else if (gps->flag & GP_STROKE_2DSPACE) { + /* 2D strokes (dataspace) - for any 2D view (i.e. everything other than 3D view) */ + return (sa->spacetype != SPACE_VIEW3D); + } + else { + /* view aligned - anything goes */ + return true; + } +} + +/* Check whether given stroke can be edited in the current context */ +bool ED_gpencil_stroke_can_use(const bContext *C, const bGPDstroke *gps) +{ + ScrArea *sa = CTX_wm_area(C); + return ED_gpencil_stroke_can_use_direct(sa, gps); +} + +/* ******************************************************** */ + /* Init handling for space-conversion function (from passed-in parameters) */ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) { |