diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index 144621fb184e..ef74f2dd41aa 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -3780,6 +3780,13 @@ void RasterizerStorageGLES2::skeleton_attach_canvas_item(RID p_skeleton, RID p_c ERR_FAIL_COND(!p_canvas_item.is_valid()); if (p_attach) { +#ifdef DEV_ENABLED + // skeleton_attach_canvas_item() is not bound, + // and checks in canvas_item_attach_skeleton() should prevent this, + // but there isn't much harm in a DEV_ENABLED check here. + int64_t found = skeleton->linked_canvas_items.find(p_canvas_item); + ERR_FAIL_COND(found != -1); +#endif skeleton->linked_canvas_items.push_back(p_canvas_item); } else { int64_t found = skeleton->linked_canvas_items.find(p_canvas_item); diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 54a288302ee4..9dec192f4c6d 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -5322,6 +5322,13 @@ void RasterizerStorageGLES3::skeleton_attach_canvas_item(RID p_skeleton, RID p_c ERR_FAIL_COND(!p_canvas_item.is_valid()); if (p_attach) { +#ifdef DEV_ENABLED + // skeleton_attach_canvas_item() is not bound, + // and checks in canvas_item_attach_skeleton() should prevent this, + // but there isn't much harm in a DEV_ENABLED check here. + int64_t found = skeleton->linked_canvas_items.find(p_canvas_item); + ERR_FAIL_COND(found != -1); +#endif skeleton->linked_canvas_items.push_back(p_canvas_item); } else { int64_t found = skeleton->linked_canvas_items.find(p_canvas_item);