Fix #119384: Outliner crash extend mode toggle on objects sharing data #119416

Closed
Philipp Oeser wants to merge 3 commits from lichtwerk/blender:119384 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

This builds upon 8e060b44da

Above commit also checked shared data against the active object,
however objects not being active can also share data with other objects
in multi-object-editing. This is now checked, so the shared icon is used
for them as well as disabeling "extend" (same as in 8e060b44da).

Noticed other issues with this feature:

  • extending should only show in the tooltip for pose and editmode
    (outliner_item_mode_toggle ignores other modes for extending)
  • removing a particular item (if it is not the active) from a mode does
    not work well/at all.
  • these will be addressed separately though
This builds upon 8e060b44da04 Above commit also checked shared data against the **active** object, however objects not being active can also share data with other objects in multi-object-editing. This is now checked, so the shared icon is used for them as well as disabeling "extend" (same as in 8e060b44da04). Noticed other issues with this feature: - extending should only show in the tooltip for pose and editmode (`outliner_item_mode_toggle` ignores other modes for extending) - removing a particular item (if it is not the active) from a mode does not work well/at all. - these will be addressed separately though
Philipp Oeser added 1 commit 2024-03-13 11:54:29 +01:00
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
d5baf518c0
Fix #119384: Outliner crash extend mode toggle on objects sharing data
This builds upon 8e060b44da

Above commit also checked shared data against the **active** object,
however objects not being active can also share data with other objects
in multi-object-editing. This is now checked, so the shared icon is used
for them as well as disabeling "extend" (same as in 8e060b44da).

Noticed other issues with this feature:
- extending should only show in the tooltip for pose and editmode
(`outliner_item_mode_toggle` ignores other modes for extending)
- removing a particular item (if it is not the active) from a mode does
not work well/at all.
- these will be addressed separately though
Philipp Oeser added this to the User Interface project 2024-03-13 11:54:43 +01:00
Philipp Oeser requested review from Hans Goudey 2024-03-13 11:54:54 +01:00
Philipp Oeser requested review from Julian Eisel 2024-03-13 11:55:01 +01:00
Author
Member

@blender-bot build

@blender-bot build
Author
Member

FYI: linting fails because of some other commit (probably 0b19f1f4a0)

FYI: linting fails because of some other commit (probably 0b19f1f4a0b1)
Hans Goudey requested changes 2024-03-13 13:57:49 +01:00
@ -2145,0 +2146,4 @@
Object *ob,
Object *ob_active)
{
bool object_data_shared = (ob->data == ob_active->data);
Member

Looks like this can be changed to if (ob->data == ob_active->data) { return true; }

Looks like this can be changed to `if (ob->data == ob_active->data) { return true; }`
lichtwerk marked this conversation as resolved
@ -2145,0 +2149,4 @@
bool object_data_shared = (ob->data == ob_active->data);
/* If the ID has multiple users, also check if any object using it is in the same mode as the
* active object. */
if (static_cast<const ID *>(ob->data)->us > 1) {
Member

Flip the condition and return early in this case

Flip the condition and return early in this case
lichtwerk marked this conversation as resolved
@ -2145,0 +2155,4 @@
Vector<Object *> objects_in_mode = BKE_view_layer_array_from_objects_in_mode_params(
tvc->scene, tvc->view_layer, nullptr, &params);
for (Object *object : objects_in_mode) {
object_data_shared |= object->data == ob->data;
Member

Return true in this case rather than changing a boolean, then return false at the end.

Return true in this case rather than changing a boolean, then return false at the end.
lichtwerk marked this conversation as resolved
Julian Eisel requested changes 2024-03-13 13:58:21 +01:00
@ -2142,6 +2142,26 @@ static void outliner_buttons(const bContext *C,
}
}
static bool outliner_mode_toggle_object_data_shared(TreeViewContext *tvc,
Member

This name is not clear to me. It reads like it's toggling some shared state of the object-data. How about outliner_is_object_data_shared_in_mode()?

This name is not clear to me. It reads like it's toggling some shared state of the object-data. How about `outliner_is_object_data_shared_in_mode()`?
lichtwerk marked this conversation as resolved
@ -2144,1 +2144,4 @@
static bool outliner_mode_toggle_object_data_shared(TreeViewContext *tvc,
Object *ob,
Object *ob_active)
Member

Both these can be const I think.

Both these can be `const` I think.
lichtwerk marked this conversation as resolved
@ -2145,0 +2146,4 @@
Object *ob,
Object *ob_active)
{
bool object_data_shared = (ob->data == ob_active->data);
Member

This object_data_shared variable seems to just make things more confusing (and less efficient), I don't see a need for it. Just return once you have found an object sharing the data. Like

{
  if (...) {
    return true;
  }

  for (...) {
    if (...) {
      return true;
    }
  }
  return false;
}

This makes the function flow much easier to follow, there's no local "state" variable to keep track of.

This `object_data_shared` variable seems to just make things more confusing (and less efficient), I don't see a need for it. Just return once you have found an object sharing the data. Like ```C { if (...) { return true; } for (...) { if (...) { return true; } } return false; } ``` This makes the function flow much easier to follow, there's no local "state" variable to keep track of.
lichtwerk marked this conversation as resolved
@ -2145,0 +2152,4 @@
if (static_cast<const ID *>(ob->data)->us > 1) {
ObjectsInModeParams params = {0};
params.object_mode = ob_active->mode;
Vector<Object *> objects_in_mode = BKE_view_layer_array_from_objects_in_mode_params(
Member

I'm not sure if it's a great idea to call this here, since it gets called for every object in every redraw. You could store this in TreeViewContext. What do you think @HooglyBoogly?

Also I guess this will contain both ob and ob_active, so the function will always return true?
I wonder if the original ob->data == tvc.obact->data check also had that issue, I guess it did.

I'm not sure if it's a great idea to call this here, since it gets called for every object in every redraw. You could store this in `TreeViewContext`. What do you think @HooglyBoogly? Also I guess this will contain both `ob` and `ob_active`, so the function will always return true? I wonder if the original `ob->data == tvc.obact->data` check also had that issue, I guess it did.
@ -2145,0 +2154,4 @@
params.object_mode = ob_active->mode;
Vector<Object *> objects_in_mode = BKE_view_layer_array_from_objects_in_mode_params(
tvc->scene, tvc->view_layer, nullptr, &params);
for (Object *object : objects_in_mode) {
Member

It's easy to confuse ob and object. Better name this iter_object or something clearer. Also, const.

It's easy to confuse `ob` and `object`. Better name this `iter_object` or something clearer. Also, `const`.
lichtwerk marked this conversation as resolved
Philipp Oeser added 1 commit 2024-03-13 14:56:10 +01:00
b15196b11c address review comments
- except performance concerns
- except for function (falsly) returning true -- which I cannot repro
Philipp Oeser added 1 commit 2024-03-13 15:06:56 +01:00
Author
Member

Will target main branch (since running out of time for 4.1)

Will target main branch (since running out of time for 4.1)
lichtwerk changed target branch from blender-v4.1-release to main 2024-03-13 15:27:46 +01:00
Author
Member

I think it is apparent that some other solution needs to be found, will step down from this one for now

I think it is apparent that some other solution needs to be found, will step down from this one for now
Philipp Oeser closed this pull request 2024-03-14 11:09:29 +01:00

Pull request closed

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
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#119416
No description provided.