Fix #119615: Anim, Crash with NLA tweak mode and linked Armatures #119632

Merged

Fix a crash when inserting a key with tweak mode enabled, but where
AnimData::actstrip was NULL.

The root cause of this is that two pointers in the AnimData struct
(act_track and actstrip) are expected to be set when NLA tweak mode
is enabled, BUT these are not exposed to RNA and thus invisible to the
library overrides system. As such, they are NULL when loading from disk,
while the ADT_NLA_EDIT_ON flag still indicates they are to be used.

Rather than adding a NULL pointer check (and having to add that in many
more places), I used this two-pronged approach:

  • Extend the 'NLA tweakmode' override apply code, to set the act_track
    and actstrip pointers when they are incorrectly NULL. This is done
    by lookup of the track and strip by name.
  • Add versioning code to exit out of tweak mode whenever the
    ADT_NLA_EDIT_ON flag is set, but those two pointers are still NULL.

The last step was necessary with the example file attached to the bug
report, as that was saved with a buggy blender version. New saves work
just fine.

Fix a crash when inserting a key with tweak mode enabled, but where `AnimData::actstrip` was NULL. The root cause of this is that two pointers in the `AnimData` struct (`act_track` and `actstrip`) are expected to be set when NLA tweak mode is enabled, BUT these are not exposed to RNA and thus invisible to the library overrides system. As such, they are NULL when loading from disk, while the `ADT_NLA_EDIT_ON` flag still indicates they are to be used. Rather than adding a NULL pointer check (and having to add that in many more places), I used this two-pronged approach: - Extend the 'NLA tweakmode' override apply code, to set the `act_track` and `actstrip` pointers when they are incorrectly NULL. This is done by lookup of the track and strip by name. - Add versioning code to exit out of tweak mode whenever the `ADT_NLA_EDIT_ON` flag is set, but those two pointers are still NULL. The last step was necessary with the example file attached to the bug report, as that was saved with a buggy blender version. New saves work just fine.
Sybren A. Stüvel added this to the 4.1 milestone 2024-03-18 18:12:01 +01:00
Sybren A. Stüvel added the
Module
Animation & Rigging
Priority
High
labels 2024-03-18 18:12:01 +01:00
Sybren A. Stüvel requested review from Christoph Lendenfeld 2024-03-18 18:12:42 +01:00
Sybren A. Stüvel requested review from Nate Rupsis 2024-03-18 18:12:42 +01:00
Sybren A. Stüvel changed target branch from main to blender-v4.1-release 2024-03-18 18:15:07 +01:00
Author
Member

@blender-bot build

@blender-bot build
Nate Rupsis approved these changes 2024-03-18 18:28:53 +01:00
Nate Rupsis left a comment
Member

Changes make sense. Approved.

Changes make sense. Approved.
@ -397,1 +397,4 @@
void BKE_nlastrip_set_active(struct AnimData *adt, struct NlaStrip *strip);
/**
* Find the NLA-strip with the given name within the given track.
*/
Member

Might be worth mentioning what happens if no strip is found given the name.

Might be worth mentioning what happens if no strip is found given the name.
Christoph Lendenfeld approved these changes 2024-03-18 22:12:09 +01:00
Christoph Lendenfeld left a comment
Member

thanks for the fix. I like the approach
what a wild bug

thanks for the fix. I like the approach what a wild bug
Sybren A. Stüvel force-pushed pr/fix-119615-nla-tweakmode-crash from 094f3e4a4e to ac3a1386fa 2024-03-19 10:08:48 +01:00 Compare
Sybren A. Stüvel force-pushed pr/fix-119615-nla-tweakmode-crash from ac3a1386fa to cf0a5d1581 2024-03-19 10:09:25 +01:00 Compare
Author
Member

@blender-bot build

@blender-bot build
Sybren A. Stüvel merged commit c0c7e34bab into blender-v4.1-release 2024-03-19 10:45:43 +01:00
Sybren A. Stüvel deleted branch pr/fix-119615-nla-tweakmode-crash 2024-03-19 10:45:49 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
Asset Browser Project
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#119632
No description provided.