Text datablocks don't self-register when getting a .00x suffix #89532
Labels
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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#89532
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Although all text blocks that don't have an extension use script highlighting, only those which end in exactly
.py
allow for the "Register" checkbox's functionality to work. I think this design forgot to take into account that Blender will slap a .001 suffix after duplicates datablocks, which can cause scripts to fail to register themselves pretty easily, and in a way that is very hard to troubleshoot for a user who is not in the know.Example cases
For example, someone might rig two characters in two files, and create rig UI scripts for them, both named
rig_ui.py
. Then, since they're working on a small hobby level production, they will append the characters into the same scene, resulting in the appended script getting a .001 suffix and failing to execute.In another case, one might want to append multiple of the same character, resulting in the same issue, and in this case naming the rig script in a unique way won't even help.
Even in a real production where linking allows these datablocks to have their own namespaces, sometimes there's small flaws in pipeline tools, or somebody makes a small mistake, and a script can end up with a .001 suffix in a plethora of ways.
Solutions
I would propose allowing scripts to use the Register feature not only if their names end in exactly
.py
but also.py.###
(I think there's already naming util functions to check for this)Alternative would be to put the .001 before the .py when a duplicate appears but I think that would require adding a special case to much deeper code which probably nobody wants to do ;).
This was also mentioned in an Animation Module meeting once upon a time and according to my memory there was general agreement toward the first solution, but my memories are faded and I'm biased.
CC @dr.sybren @BassamKurdali @LucianoMunoz @icappiello @jpbouza-4 Thoughts? :)
Added subscribers: @icappiello, @Bassam, @LucianoMunoz, @jpbouza-4, @dr.sybren, @Mets
Added subscriber: @BassamKurdali
Added subscriber: @lichtwerk
Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'
can confirm the issue, will leave classification up to module devs
+1 for the first solution. The exact datablock name is less important now that they cannot be directly imported any more;
import rig_ui
used to work for importing a text datablockrig_ui.py
; now you needrig_ui = bpy.data.texts['rig_ui'].as_module()
for this.This might require changing the logic in
ED_text_is_syntax_highlight_supported()
a bit. Currently it always returnstrue
for any datablock ending in a.###
numerical suffix. If we say thatblabla.xxx.###
should be treated the same asblablabla.xxx
, the current logic in that function is not suitable any more.Furthermore,
TEXT_MT_text
should be adjusted. Currently it's the menu's Python code that determines whether the "Register" checkbox is enabled or not. IMO this is a bad design -- the ability to register a text datablock should be handled in RNA and not in UI code.Added subscriber: @ideasman42
Since the scripts are executed instead of loading as a module there is no longer a need to have any constraint on the naming.
Seems reasonable this can be handled separately.
This can't be done in RNA, it's only possible to conditionally be read-only, where as for this we would only want to grey it out.
Submitted D12181, this removes the check for the extension entirely.
This issue was referenced by
3e775a4fc5
Changed status from 'Needs Developer To Reproduce' to: 'Resolved'