Fix #113255: LineStyle modifiers cannot be accessed by name anymore #113290

Merged
Philipp Oeser merged 1 commits from lichtwerk/blender:113255 into blender-v4.0-release 2023-10-11 13:35:11 +02:00
Member

Caused by 6a49041be3 .

Above commit checks an existing nameproperty for collection items, but
it does so in a way that it only checks the "parent" type. If these are
"subclassed" though, we might not have the nameproperty defined on the
"parent" class (but on the subclass instead).
Code would then error out with e.g. "FreestyleLineStyle.color_modifiers
does not support string lookups".

In the case of the report the following happened.

  • linestyle modifiers (LineStyleModifier) can be any of:
    -- color_modifiers / LineStyleColorModifier
    -- alpha_modifiers / LineStyleAlphaModifier
    -- thickness_modifiers / LineStyleThicknessModifier
    -- geometry_modifiers / LineStyleGeometryModifier

But all of the above have subtypes, e.g.
LineStyleColorModifier_AlongStroke,
LineStyleColorModifier_DistanceFromCamera, ...
Currently, the nameproperty is not defined e.g. on the
LineStyleColorModifier (but instead on the subtypes).

Prior to 6a49041be3 (without
RNA_property_collection_lookup_string_has_nameprop in place),
pyrna_prop_collection_subscript_str could still actually find the
nameprop because it iterates into the collection and got it on the
actual Item (LineStyleColorModifier_DistanceFromCamera instead of
LineStyleColorModifier).

So while it might be possible to refine
RNA_property_collection_lookup_string_has_nameprop to descend into
subclasses (I didnt find an obvious way though other than scanning all
existing modifiers [not modifier types -- we would need a way to find
all types that inherit from e.g. LineStyleColorModifier] which kind of
defeats the purpose of checking this early), this PR moves the name
definition from the subclass to the parent class (so way from
rna_def_modifier_type_common) -- and this way,
RNA_property_collection_lookup_string_has_nameprop can properly pick
up the nameprop. It does a bit of code duplication though.

Caused by 6a49041be3d5 . Above commit checks an existing nameproperty for collection items, but it does so in a way that it only checks the "parent" type. If these are "subclassed" though, we might not have the nameproperty defined on the "parent" class (but on the subclass instead). Code would then error out with e.g. "FreestyleLineStyle.color_modifiers does not support string lookups". In the case of the report the following happened. - linestyle modifiers (`LineStyleModifier`) can be any of: -- `color_modifiers` / `LineStyleColorModifier` -- `alpha_modifiers` / `LineStyleAlphaModifier` -- `thickness_modifiers` / `LineStyleThicknessModifier` -- `geometry_modifiers` / `LineStyleGeometryModifier` But all of the above have subtypes, e.g. `LineStyleColorModifier_AlongStroke`, `LineStyleColorModifier_DistanceFromCamera`, ... Currently, the `nameproperty` is not defined e.g. on the `LineStyleColorModifier` (but instead on the subtypes). Prior to 6a49041be3d5 (without `RNA_property_collection_lookup_string_has_nameprop` in place), `pyrna_prop_collection_subscript_str` could still actually find the nameprop because it iterates into the collection and got it on the actual Item (`LineStyleColorModifier_DistanceFromCamera` instead of `LineStyleColorModifier`). So while it might be possible to refine `RNA_property_collection_lookup_string_has_nameprop` to descend into subclasses (I didnt find an obvious way though other than scanning all existing modifiers [not modifier types -- we would need a way to find all types that inherit from e.g. `LineStyleColorModifier`] which kind of defeats the purpose of checking this early), this PR moves the name definition from the subclass to the parent class (so way from `rna_def_modifier_type_common`) -- and this way, `RNA_property_collection_lookup_string_has_nameprop` can properly pick up the nameprop. It does a bit of code duplication though.
Philipp Oeser added 1 commit 2023-10-05 14:45:28 +02:00
89d0969125 Fix #113255: LineStyle modifiers cannot be accessed by name anymore
Caused by 6a49041be3 .

Above commit checks an existing nameproperty for collection items, but
it does so in a way that it only checks the "parent" type. If these are
"subclassed" though, we might not have the nameproperty defined on the
"parent" class (but on the subclass instead).
Code would then error out with e.g. "FreestyleLineStyle.color_modifiers
does not support string lookups".

In the case of the report the following happened.

- linestyle modifiers (`LineStyleModifier`) can be any of:
-- `color_modifiers` / `LineStyleColorModifier`
-- `alpha_modifiers` / `LineStyleAlphaModifier`
-- `thickness_modifiers` / `LineStyleThicknessModifier`
-- `geometry_modifiers` / `LineStyleGeometryModifier`

But all of the above have subtypes, e.g.
`LineStyleColorModifier_AlongStroke`,
`LineStyleColorModifier_DistanceFromCamera`, ...
Currently, the `nameproperty` is not defined e.g. on the
`LineStyleColorModifier` (but instead on the subtypes).

Prior to 6a49041be3 (without
`RNA_property_collection_lookup_string_has_nameprop` in place),
`pyrna_prop_collection_subscript_str` could still actually find the
nameprop because it iterates into the collection and got it on the
actual Item (`LineStyleColorModifier_DistanceFromCamera` instead of
`LineStyleColorModifier`).

So while it might be possible to refine
`RNA_property_collection_lookup_string_has_nameprop` to descend into
subclasses (I didnt find an obvious way though other than scanning all
existing modifiers [not modifier types -- we would need a way to find
all types that inherit from e.g. `LineStyleColorModifier`] which kind of
defeats the purpose of checking this early), this PR moves the name
definition from the subclass to the parent class (so way from
`rna_def_modifier_type_common`) -- and this way,
`RNA_property_collection_lookup_string_has_nameprop` can properly pick
up the nameprop. It does a bit of code duplication though.
Philipp Oeser requested review from Campbell Barton 2023-10-05 14:45:42 +02:00
Philipp Oeser added this to the Core project 2023-10-05 14:46:33 +02:00
Philipp Oeser added the
Interest
Python API
Interest
Freestyle
labels 2023-10-05 14:46:51 +02:00
Campbell Barton approved these changes 2023-10-11 13:15:30 +02:00
Campbell Barton left a comment
Owner

At first it seemed like this should be able to use a single name property, although having to select the listbase to use makes this unnecessarily awkward (attached patch for reference), we could also have a unique naming function that doesn't require the listbase, but the advantages are minimal.
So this PR looks like the way to go.

At first it seemed like this should be able to use a single name property, although having to select the listbase to use makes this unnecessarily awkward _(attached patch for reference)_, we could also have a unique naming function that doesn't require the listbase, but the advantages are minimal. So this PR looks like the way to go.
Philipp Oeser merged commit f8d38b65a4 into blender-v4.0-release 2023-10-11 13:35:11 +02:00
Philipp Oeser deleted branch 113255 2023-10-11 13:35:16 +02:00
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
2 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#113290
No description provided.