NLA is editable even when the animation data is linked #105260

Open
opened 2023-02-27 18:10:25 +01:00 by Sybren A. Stüvel · 8 comments

Blender Version
Broken: 2.80 to current main branch (96abaae9ac57e3833f862bc0b562d2fe7a95f702)
Worked: probably never

Short description of error
The NLA is editable, even when the animation data is linked and thus should be read-only.

Exact steps for others to reproduce the error

  • Extract the attached ZIP
  • Open nla-link-test.blend
  • Move the strip in the NLA
  • Save and reload the file
  • See that the strip edit has not been saved to disk.

Observed behaviour: the NLA strip can be moved.

Expected behaviour: the NLA data of the linked object should be read-only. Just like the cube itself (you cannot move it).

**Blender Version** Broken: 2.80 to current main branch (`96abaae9ac57e3833f862bc0b562d2fe7a95f702`) Worked: probably never **Short description of error** The NLA is editable, even when the animation data is linked and thus should be read-only. **Exact steps for others to reproduce the error** - Extract the attached ZIP - Open `nla-link-test.blend` - Move the strip in the NLA - Save and reload the file - See that the strip edit has not been saved to disk. Observed behaviour: the NLA strip can be moved. Expected behaviour: the NLA data of the linked object should be read-only. Just like the cube itself (you cannot move it).
Member

Subscribing.

Subscribing.

looks like the way to disable editing for linked NLA is in nla_select.c and nla_edit.c
wherever you see:

/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
}

replace it with:

/* get editor data and make sure active object is not linked */
Object *ob = CTX_data_active_object(C);
if ((ANIM_animdata_get_context(C, &ac) == 0) || (ob && ob->id.lib)) {
return OPERATOR_CANCELLED;
}

This cancels all attempts at editing when the active object is a linked one.

I tested it and can't edit anything in the NLA editor for the linked cube, but I'm brand new to the blender code base, don't want to presume anything.

*looks like* the way to disable editing for linked NLA is in nla_select.c and nla_edit.c wherever you see: /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; } replace it with: /* get editor data and make sure active object is not linked */ Object *ob = CTX_data_active_object(C); if ((ANIM_animdata_get_context(C, &ac) == 0) || (ob && ob->id.lib)) { return OPERATOR_CANCELLED; } This cancels all attempts at editing when the active object is a linked one. I tested it and can't edit anything in the NLA editor for the linked cube, but I'm brand new to the blender code base, don't want to presume anything.
Author
Member

Thanks @Jay-Mckee for helping out :)

Unfortunately this is not enough. The animation data may be owned by other objects (when the "Selected Only" filter is turned off), so the check will have to be done somewhere else.

As for the check itself, that shouldn't access ob->id.lib directly, but rather use ID_IS_LINKED(ob->id). There are a bunch of macros in DNA_ID.h that can help with these kind of tests.

Thanks @Jay-Mckee for helping out :) Unfortunately this is not enough. The animation data may be owned by other objects (when the "Selected Only" filter is turned off), so the check will have to be done somewhere else. As for the check itself, that shouldn't access `ob->id.lib` directly, but rather use `ID_IS_LINKED(ob->id)`. There are a bunch of macros in `DNA_ID.h` that can help with these kind of tests.
Contributor

Probably related: The NLA track edibility can be toggled by pressing tab.

Probably related: The NLA track edibility can be toggled by pressing tab.
Member

Testing this in 3.5.1

the last step in this "See that the strip edit has not been saved to disk." is working for me, meaning I can open and edit the animation strip data and save it and it opens correctly.

@cgtinker you are correct the UI click for unlock and mute for an object that is linked in and not overridden is not possible.

Hitting TAB does seem to get around the flag that says it you can't edit a linked datablock.
So in this case the main "fix" is that the TAB shortcut key for some reason is able to lock/unlock the track while it says it shouldn't be able to
image

Testing this in 3.5.1 the last step in this "See that the strip edit has not been saved to disk." is working for me, meaning I can open and edit the animation strip data and save it and it opens correctly. @cgtinker you are correct the UI click for unlock and mute for an object that is linked in and not overridden is not possible. Hitting TAB does seem to get around the flag that says it you can't edit a linked datablock. So in this case the main "fix" is that the TAB shortcut key for some reason is able to lock/unlock the track while it says it shouldn't be able to ![image](/attachments/2be6200e-4045-4453-a711-ceabe6bb826e)
Contributor

Seem like all nla edit methods filter before starting to work on nla strips – how about adding a new filter flag? B.e. ANIMFILTER_DATA_NOT_LINKED and filter using the strips id prop ID_IS_LINKED(strip->act).

This would just add a flag in various places in the end.

Seem like all nla edit methods filter before starting to work on nla strips – how about adding a new filter flag? B.e. `ANIMFILTER_DATA_NOT_LINKED` and filter using the strips id prop `ID_IS_LINKED(strip->act)`. This would just add a flag in various places in the end.
Author
Member

Seem like all nla edit methods filter before starting to work on nla strips – how about adding a new filter flag? B.e. ANIMFILTER_DATA_NOT_LINKED and filter using the strips id prop ID_IS_LINKED(strip->act).

I think ANIMFILTER_DATA_LOCAL would be a better name (I prefer avoiding negations). Then again, maybe adding the ID_IS_LINKED(strip->act) to the ANIMFILTER_FOREDIT filtering could be enough?

> Seem like all nla edit methods filter before starting to work on nla strips – how about adding a new filter flag? B.e. `ANIMFILTER_DATA_NOT_LINKED` and filter using the strips id prop `ID_IS_LINKED(strip->act)`. I think `ANIMFILTER_DATA_LOCAL` would be a better name (I prefer avoiding negations). Then again, maybe adding the `ID_IS_LINKED(strip->act)` to the `ANIMFILTER_FOREDIT` filtering could be enough?
Member

@dr.sybren , this looks like a part of #98712

@dr.sybren , this looks like a part of #98712
Sign in to join this conversation.
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
6 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#105260
No description provided.