Fix #111607: Do not unregister internal nodes #111615

Merged
YimingWu merged 2 commits from ChengduLittleA/blender:fix-111607 into main 2023-08-29 09:35:53 +02:00
Member

Registering a node with a bl_idname same as a built-in node will lead
to crash because rna_Node_unregister does not check nt->rna_ext.data
to see whether it's not null (which indicates whether this node is
registered with python or not). Now fixed.

Registering a node with a `bl_idname` same as a built-in node will lead to crash because `rna_Node_unregister` does not check `nt->rna_ext.data` to see whether it's not null (which indicates whether this node is registered with python or not). Now fixed.
YimingWu added 1 commit 2023-08-28 15:47:50 +02:00
ce78f5a24a Fix #111607: Do not unregister internal nodes
Registering a node with a `bl_idname` same as a built-in node will lead
to crash because `rna_Node_unregister` does not check `nt->rna_ext.data`
to see whether it's not null (which indicates whether this node is
registered with python or not). Now fixed.
Iliya Katushenock added this to the Nodes & Physics project 2023-08-28 15:49:58 +02:00
Iliya Katushenock added the
Module
Python API
label 2023-08-28 15:50:04 +02:00
Hans Goudey reviewed 2023-08-28 15:53:39 +02:00
@ -1769,3 +1769,3 @@
bNodeType *nt = static_cast<bNodeType *>(RNA_struct_blender_type_get(type));
if (!nt) {
/** `nt->rna_ext.data` is the python object. If it's nullptr then it's a
Member

Picky:

The /** comment format is meant for function/struct documentation. Comments inside of functions can just use /* like normal.

Also, it's a internally -> it's an internally

Picky: The `/**` comment format is meant for function/struct documentation. Comments inside of functions can just use `/*` like normal. Also, `it's a internally` -> `it's an internally`
ChengduLittleA marked this conversation as resolved
Contributor

Even though this patch prevents the crash, it looks to me like it still allows the node to be created with a duplicated identifier, no? Isn't that a problem?

Even though this patch prevents the crash, it looks to me like it still allows the node to be created with a duplicated identifier, no? Isn't that a problem?
YimingWu added 1 commit 2023-08-29 03:48:37 +02:00
Author
Member

@vitorboschi ah, the code will return null in rna_Node_unregister and error out on rna_Node_register_base, and a new node type is never created. :D

@vitorboschi ah, the code will return null in `rna_Node_unregister` and error out on `rna_Node_register_base`, and a new node type is never created. :D
Hans Goudey approved these changes 2023-08-29 03:52:01 +02:00
YimingWu merged commit 0798aae01c into main 2023-08-29 09:35:53 +02:00
YimingWu deleted branch fix-111607 2023-08-29 09:35:54 +02:00
Contributor

@vitorboschi ah, the code will return null in rna_Node_unregister and error out on rna_Node_register_base, and a new node type is never created. :D

I missed that! Thanks for the clarification!
Would it make sense to add the same check at rna_Node_register_base so we can generate a better error message when this happens? Currently it will show RuntimeError: Error: Registering node class: 'NodeDummy', bl_idname 'NodeGroupInput' could not be unregistered, which is kinda cryptic considering the user asked to register a class.

I can create a patch for that if the change is desirable.

> @vitorboschi ah, the code will return null in `rna_Node_unregister` and error out on `rna_Node_register_base`, and a new node type is never created. :D I missed that! Thanks for the clarification! Would it make sense to add the same check at `rna_Node_register_base` so we can generate a better error message when this happens? Currently it will show `RuntimeError: Error: Registering node class: 'NodeDummy', bl_idname 'NodeGroupInput' could not be unregistered`, which is kinda cryptic considering the user asked to register a class. I can create a patch for that if the change is desirable.
Author
Member

@vitorboschi Oh it's definitely better if you could make a more clarified message, yes :D

@vitorboschi Oh it's definitely better if you could make a more clarified message, yes :D
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 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#111615
No description provided.