Change "Link materials to the object or the object's data" on multiple objects #90907

Closed
opened 2021-08-25 08:40:59 +02:00 by Staffan Wikström · 10 comments

In 3.0.0 alpha there is a bug preventing me from changing "Link materials to the object or the object's data" on multiple objects by alt-clicking on the drop down.
This worked in 2.93.3.

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: Quadro P3000/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 461.92

Blender Version
Broken: version: 3.0.0 Alpha, branch: master, commit date: 2021-08-24 18:38, hash: 5ef3afd87c
Worked: 2.93.3
Caused by 1a81d268a1

Short description of error
[Please fill out a short description of the error here]

Exact steps for others to reproduce the error
[Please describe the exact steps needed to reproduce the issue]
[Based on the default startup or an attached .blend file (as simple as possible)]

In 3.0.0 alpha there is a bug preventing me from changing "Link materials to the object or the object's data" on multiple objects by alt-clicking on the drop down. This worked in 2.93.3. **System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: Quadro [P3000](https://archive.blender.org/developer/P3000.txt)/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 461.92 **Blender Version** Broken: version: 3.0.0 Alpha, branch: master, commit date: 2021-08-24 18:38, hash: `5ef3afd87c` Worked: 2.93.3 Caused by 1a81d268a1 **Short description of error** [Please fill out a short description of the error here] **Exact steps for others to reproduce the error** [Please describe the exact steps needed to reproduce the issue] [Based on the default startup or an attached .blend file (as simple as possible)]

Added subscriber: @staffan.wikstrom

Added subscriber: @staffan.wikstrom
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Philipp Oeser self-assigned this 2021-08-25 10:23:10 +02:00
Member

Can confirm, will check if this was intentional

Can confirm, will check if this was intentional
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123

This issue was referenced by 6845aad1a2

This issue was referenced by 6845aad1a271db9861ba54e50c97146277eead4f
Member

same is true for Copy To Selected.

Caused by 1a81d268a1

I think there is an issue with the new usage of POINTER_FROM_INT.
See 02b80276b3 for another recent issue with this.
Not totally sure how RNA handled the PointerRNA.data before, but now these are not unique across objects anymore.

So the following checks always have lptr.data and ptr.data the same [which I think causes the problem]
https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/interface/interface_handlers.c$1824
https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/interface/interface_ops.c$1038

Tried to make this unique again with (but I think I just dont understand this pointer <> int conversion...)
P2344: T90907_snippet



diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 0f6b89722a4..bd636876d66 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -1326,8 +1326,8 @@ static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index)
 
 static int rna_MaterialSlot_index(PointerRNA *ptr)
 {
-  /* There is an offset of one, so that `ptr->data` is not null. */
-  return POINTER_AS_INT(ptr->data) - 1;
+  ID *id = (ID *)ptr->owner_id;
+  return POINTER_AS_INT(ptr->data) - POINTER_AS_INT(id);
 }
 
 static int rna_MaterialSlot_material_editable(PointerRNA *ptr, const char **UNUSED(r_info))
@@ -1490,10 +1490,11 @@ static void rna_Object_material_slots_next(CollectionPropertyIterator *iter)
 static PointerRNA rna_Object_material_slots_get(CollectionPropertyIterator *iter)
 {
   PointerRNA ptr;
-  RNA_pointer_create((ID *)iter->internal.count.ptr,
+  ID *id = (ID *)iter->internal.count.ptr;
+  RNA_pointer_create(id,
                      &RNA_MaterialSlot,
                      /* Add one, so that `ptr->data` is not null. */
-                     POINTER_FROM_INT(iter->internal.count.item + 1),
+                     POINTER_FROM_INT(iter->internal.count.item + POINTER_AS_INT(id)),
                      &ptr);
   return ptr;
 }
same is true for Copy To Selected. Caused by 1a81d268a1 I think there is an issue with the new usage of POINTER_FROM_INT. See 02b80276b3 for another recent issue with this. Not totally sure how RNA handled the PointerRNA.data before, but now these are not unique across objects anymore. So the following checks always have lptr.data and ptr.data the same [which I think causes the problem] https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/interface/interface_handlers.c$1824 https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/interface/interface_ops.c$1038 Tried to make this unique again with (but I think I just dont understand this pointer <> int conversion...) [P2344: T90907_snippet](https://archive.blender.org/developer/P2344.txt) ``` diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 0f6b89722a4..bd636876d66 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1326,8 +1326,8 @@ static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index) static int rna_MaterialSlot_index(PointerRNA *ptr) { - /* There is an offset of one, so that `ptr->data` is not null. */ - return POINTER_AS_INT(ptr->data) - 1; + ID *id = (ID *)ptr->owner_id; + return POINTER_AS_INT(ptr->data) - POINTER_AS_INT(id); } static int rna_MaterialSlot_material_editable(PointerRNA *ptr, const char **UNUSED(r_info)) @@ -1490,10 +1490,11 @@ static void rna_Object_material_slots_next(CollectionPropertyIterator *iter) static PointerRNA rna_Object_material_slots_get(CollectionPropertyIterator *iter) { PointerRNA ptr; - RNA_pointer_create((ID *)iter->internal.count.ptr, + ID *id = (ID *)iter->internal.count.ptr; + RNA_pointer_create(id, &RNA_MaterialSlot, /* Add one, so that `ptr->data` is not null. */ - POINTER_FROM_INT(iter->internal.count.item + 1), + POINTER_FROM_INT(iter->internal.count.item + POINTER_AS_INT(id)), &ptr); return ptr; } ```
Philipp Oeser changed title from change "Link materials to the object or the object's data" on multiple objects to Change "Link materials to the object or the object's data" on multiple objects 2021-08-25 13:14:35 +02:00
Philipp Oeser removed their assignment 2021-08-25 13:14:35 +02:00
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

Your idea is right, there are two problems:

  • POINTER_AS_INT casts to 32 bit int internally, which messes up the pointer. Better just cast to uintptr_t and void * manually here.
  • It's also necessary to update this place: b51bd859fd.
Your idea is right, there are two problems: * `POINTER_AS_INT` casts to 32 bit `int` internally, which messes up the pointer. Better just cast to `uintptr_t` and `void *` manually here. * It's also necessary to update this place: b51bd859fd.
Philipp Oeser self-assigned this 2021-08-25 16:38:21 +02:00
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser Project (Legacy)
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
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
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#90907
No description provided.