Fix #105096: Material Utilities: Clean Material Slots fails to remove unused slots #105098

Merged
Thomas Barlow merged 2 commits from Mysteryem/blender-addons:fix_105096_material_utilities_clean_slots into main 2024-01-11 12:23:50 +01:00
Member

The code was removing material slots while iterating through them which
is generally a bad idea, and it stopped working as the addon expected in
Blender 3.0+.

The slots are now removed by counting how many slots there are and then
removing that number of slots.

The code was removing material slots while iterating through them which is generally a bad idea, and it stopped working as the addon expected in Blender 3.0+. The slots are now removed by counting how many slots there are and then removing that number of slots.
Thomas Barlow added 1 commit 2023-12-30 18:17:48 +01:00
54295f0f9f Fix #105096: Material Utilities: Clean Material Slots fails to remove unused slots
The code was removing material slots while iterating through them which
is generally a bad idea, and it stopped working as the addon expected in
Blender 3.0+.

The slots are now removed by counting how many slots there are and then
removing that number of slots.
Thomas Barlow added 1 commit 2023-12-30 18:25:30 +01:00
First-time contributor

now seams to work. thanks

now seams to work. thanks
Pratik Borhade approved these changes 2024-01-05 10:39:47 +01:00
Pratik Borhade left a comment
Member

Hi, this Indeed fixes the bug. But we already have similar Cpp operator, perhaps we can remove it from the add-on's code in future?

Hi, this Indeed fixes the bug. But we already have similar Cpp operator, perhaps we can remove it from the add-on's code in future?
Author
Member

Hi, this Indeed fixes the bug. But we already have similar Cpp operator, perhaps we can remove it from the add-on's code in future?

Yes I think it could be removed from the addon's code.

While the addon has implemented its unused material removal for more than just active/selected Objects, e.g. all Objects in the .blend, the addon's Operator only ever uses either the active or the selected Objects.

Removing from selected Objects is obsolete because that's what Object>Cleanup>Remove Unused Material Slots from the 3D View does.
And removing from the active Object is obsolete because that's what doing Remove Unused Slots from the "Material Specials" menu in Properties does.

image
image

> Hi, this Indeed fixes the bug. But we already have similar Cpp operator, perhaps we can remove it from the add-on's code in future? Yes I think it could be removed from the addon's code. While the addon has implemented its unused material removal for more than just active/selected Objects, e.g. all Objects in the .blend, the addon's Operator only ever uses either the active or the selected Objects. Removing from selected Objects is obsolete because that's what `Object`>`Cleanup`>`Remove Unused Material Slots` from the 3D View does. And removing from the active Object is obsolete because that's what doing `Remove Unused Slots` from the "Material Specials" menu in Properties does. ![image](/attachments/dcd9069c-dbc7-4069-b39d-fa4227e3e9aa) ![image](/attachments/923e397a-f0a5-404a-8dea-094b6d0e3481)
Thomas Barlow merged commit cbbe37ba5a into main 2024-01-11 12:23:50 +01:00
Thomas Barlow deleted branch fix_105096_material_utilities_clean_slots 2024-01-11 12:23:52 +01:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
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-addons#105098
No description provided.