Fix T63054: Crash on "Grease Pencil Unlink"

This operator was used only by annotations and it was part of the old legacy code.

Now, the operator is limited to annotations and cannot be used with grease pencil objects.

Also changed the tooltip to clarify it's only for annotations.
This commit is contained in:
Antonio Vazquez 2019-03-28 17:07:49 +01:00
parent 1dddb47e48
commit eeefea86cd
Notes: blender-bot 2023-03-24 17:05:22 +01:00
Referenced by issue #63109, Crash when use search bar
Referenced by issue #63059, Hair strands can be edited thru emitter in Solid/lookDev/Rendered mode
Referenced by issue #63054, Crash on "Grease Pencil Unlink"
1 changed files with 9 additions and 2 deletions

View File

@ -175,6 +175,13 @@ static bool gp_data_unlink_poll(bContext *C)
{
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
/* only unlink annotation datablocks */
if (gpd_ptr != NULL) {
bGPdata *gpd = (*gpd_ptr);
if ((gpd->flag & GP_DATA_ANNOTATIONS) == 0) {
return false;
}
}
/* if we have access to some active data, make sure there's a datablock before enabling this */
return (gpd_ptr && *gpd_ptr);
}
@ -206,9 +213,9 @@ static int gp_data_unlink_exec(bContext *C, wmOperator *op)
void GPENCIL_OT_data_unlink(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Grease Pencil Unlink";
ot->name = "Annotation Unlink";
ot->idname = "GPENCIL_OT_data_unlink";
ot->description = "Unlink active Grease Pencil data-block";
ot->description = "Unlink active Annotation data-block";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* callbacks */