Fix #111024: Crash when adding attribute to curve object #111036

Merged
Pratik Borhade merged 5 commits from PratikPB2123/blender:111024-cv-vgroup into main 2023-08-12 07:37:46 +02:00
Member

After 12ef20990b, attributes and vertex group names were checked
simulatanously to fix the name collision. But this results in crash when
new attribute is added to curve object (it searches for vertex group
list). To avoid the crash, check for supported id types.

After 12ef20990b, attributes and vertex group names were checked simulatanously to fix the name collision. But this results in crash when new attribute is added to curve object (it searches for vertex group list). To avoid the crash, check for supported id types.
Pratik Borhade added 1 commit 2023-08-11 08:28:13 +02:00
0f77fce802 Fix #111024: Crash when adding attribute to curve object
After 12ef20990b, attributes and vertex group names were checked
simulatanously to fix the name collision. But this results in crash when
new attribute is added to curve object (when it searches for vertex group
list). To avoid the crash, check for supported id types.
Pratik Borhade requested review from Philipp Oeser 2023-08-11 08:28:24 +02:00
Pratik Borhade added the
Module
Modeling
label 2023-08-11 08:28:31 +02:00
Member

Ah, how could that have slipped through? Thx working on this, it would work just fine..

Two things:

  • Personally, I would do the check not in BKE_defgroup_unique_name_check, but already in BKE_id_attribute_and_defgroup_unique_name_check
    -- BKE_defgroup_unique_name_check is called from other places where we already know we have a valid ID (so it would be redundant in that case)
  • the check duplicates code from BKE_object_supports_vertex_groups
    -- maybe we could add BKE_id_supports_vertex_groups and use that (for this fix as well as in BKE_object_supports_vertex_groups)?
    -- this way we dont risk this running out of sync in case other IDs gain vertex groups supprt at a later point in time

Will also add @HooglyBoogly here

Ah, how could that have slipped through? Thx working on this, it would work just fine.. Two things: - Personally, I would do the check not in `BKE_defgroup_unique_name_check`, but already in `BKE_id_attribute_and_defgroup_unique_name_check` -- `BKE_defgroup_unique_name_check` is called from other places where we already know we have a valid ID (so it would be redundant in that case) - the check duplicates code from `BKE_object_supports_vertex_groups` -- maybe we could add `BKE_id_supports_vertex_groups` and use that (for this fix as well as in `BKE_object_supports_vertex_groups`)? -- this way we dont risk this running out of sync in case other IDs gain vertex groups supprt at a later point in time Will also add @HooglyBoogly here
Philipp Oeser requested review from Hans Goudey 2023-08-11 09:35:56 +02:00
Author
Member

maybe we could add BKE_id_supports_vertex_groups and use that

Thanks. I exactly had a thought to include the same function 😃 (use of it will be less since BKE_object_supports_vertex_groups is used everywhere. So decided to keep the scope limited)

> maybe we could add BKE_id_supports_vertex_groups and use that Thanks. I exactly had a thought to include the same function 😃 (use of it will be less since `BKE_object_supports_vertex_groups` is used everywhere. So decided to keep the scope limited)
Pratik Borhade added 1 commit 2023-08-11 12:06:29 +02:00
Pratik Borhade added 1 commit 2023-08-11 13:19:22 +02:00
0dbfba3360 Cleanup: declare new function in header
And use it in BKE_id_attribute_and_defgroup_unique_name_check
Author
Member

I would do the check not in BKE_defgroup_unique_name_check
maybe we could add BKE_id_supports_vertex_groups

Both changes are included now :)

> I would do the check not in BKE_defgroup_unique_name_check > maybe we could add BKE_id_supports_vertex_groups Both changes are included now :)
Philipp Oeser reviewed 2023-08-11 14:19:39 +02:00
Philipp Oeser left a comment
Member

Nitpick just out of curiosity.

Other than that, tested and worked fine.

Nitpick just out of curiosity. Other than that, tested and worked fine.
@ -26,6 +26,7 @@ struct MDeformVert;
struct Object;
struct bDeformGroup;
const bool BKE_id_supports_vertex_groups(const struct ID *id);
Member

Why return const ?

Why return `const` ?
Author
Member

removed, thanks.
No need to return const since return type is primitive data 😅

removed, thanks. No need to return `const` since return type is primitive data 😅
Pratik Borhade added 1 commit 2023-08-11 14:35:30 +02:00
Philipp Oeser approved these changes 2023-08-11 14:57:20 +02:00
Philipp Oeser left a comment
Member

LGTM now, would really prefer that @HooglyBoogly checks as well though.

LGTM now, would really prefer that @HooglyBoogly checks as well though.
Hans Goudey approved these changes 2023-08-11 16:41:26 +02:00
Hans Goudey left a comment
Member

Looks good, thanks!

Looks good, thanks!
@ -447,1 +445,4 @@
bool BKE_object_supports_vertex_groups(const Object *ob)
{
const ID *id = (const ID *)ob->data;
Member

Use static_cast

Use `static_cast`
Pratik Borhade added 1 commit 2023-08-12 07:35:24 +02:00
Pratik Borhade merged commit d87db8d569 into main 2023-08-12 07:37:46 +02:00
Pratik Borhade deleted branch 111024-cv-vgroup 2023-08-12 07:37:47 +02:00
Author
Member

Merged, thanks for reviewing :)

Merged, thanks for reviewing :)
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#111036
No description provided.