Fix #119384: Update Sharing Objects When Changing Modes #119759

Closed
Harley Acheson wants to merge 2 commits from Harley/blender:FixSharedDataCrash into main

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

When toggling one object in and out of edit mode, we need to update
the edit mode flag on all objects sharing the same data. Otherwise
some unrelated object might be in OB_MODE_EDIT but suddenly lose their
data->edit_mesh. These being out sync can cause various crashes. This
also corrects the icon shown in Outliner when another object is in edit
mode that shares its data.


Offered as (yet another) alternative to #119704. That PR disallows changing modes for objects that have data that is shared with another object that is in edit mode. This PR allows it to work, rather than crash.

When toggling one object in and out of edit mode, we need to update the edit mode flag on all objects sharing the same data. Otherwise some unrelated object might be in OB_MODE_EDIT but suddenly lose their data->edit_mesh. These being out sync can cause various crashes. This also corrects the icon shown in Outliner when another object is in edit mode that shares its data. --- Offered as (yet another) alternative to #119704. That PR disallows changing modes for objects that have data that is shared with another object that is in edit mode. This PR allows it to work, rather than crash.
Harley Acheson added 1 commit 2024-03-21 19:51:34 +01:00
505438e34f Fix #119384: Update Sharing Objects When Changing Modes
When toggling one object in and out of edit mode, we need to update
the edit mode flag on all objects sharing the same data. Otherwise
some unrelated object might be in OB_MODE_EDIT but suddenly lose their
data->edit_mesh. These being out sync can cause various crashes. This
also corrects the icon shown in Outliner when another object is in edit
mode that shares its data.
Harley Acheson added this to the User Interface project 2024-03-21 19:51:46 +01:00
Harley Acheson requested review from Hans Goudey 2024-03-21 19:51:53 +01:00
Harley Acheson requested review from Philipp Oeser 2024-03-21 19:52:19 +01:00
Hans Goudey requested changes 2024-03-21 20:27:41 +01:00
Hans Goudey left a comment
Member

Big picture makes sense to me. We're getting there!

Big picture makes sense to me. We're getting there!
@ -2178,6 +2178,11 @@ static void outliner_draw_mode_column_toggle(uiBlock *block,
const bool object_data_shared = (ob->data == ob_active->data);
draw_active_icon = draw_active_icon || object_data_shared;
if (!draw_active_icon && BKE_object_is_in_editmode(ob)) {
Member

BKE_object_is_in_editmode still seems not right here. Feels like this shouldn't be specific to edit mode here.

Maybe comparing the modes is enough?

`BKE_object_is_in_editmode` still seems not right here. Feels like this shouldn't be specific to edit mode here. Maybe comparing the modes is enough?
Author
Member

I need to call BKE_object_is_in_editmode because it checks the mesh>edit_mesh (and equivalent for other object types) rather than relying on the mode flags.

I need to call `BKE_object_is_in_editmode` because it checks the mesh>edit_mesh (and equivalent for other object types) rather than relying on the mode flags.
Harley marked this conversation as resolved
@ -94,2 +94,4 @@
if (changed) {
ED_object_base_select(base, BA_DESELECT);
/* All objects sharing this same data have to come out of edit mode. */
LISTBASE_FOREACH (Object *, obtest, &bmain->objects) {
Member

How about trying to call ED_object_editmode_exit_ex for every object with the same data? I think that handles some other important update tags, etc. when exiting the mode.

How about trying to call `ED_object_editmode_exit_ex` for every object with the same data? I think that handles some other important update tags, etc. when exiting the mode.
Harley marked this conversation as resolved
@ -96,0 +96,4 @@
/* All objects sharing this same data have to come out of edit mode. */
LISTBASE_FOREACH (Object *, obtest, &bmain->objects) {
if (obtest->data == ob->data) {
obtest->mode &= ~OB_MODE_EDIT;
Member

ob_iter is a more obvious variable name with fewer extra connotations

`ob_iter` is a more obvious variable name with fewer extra connotations
Harley marked this conversation as resolved
Harley Acheson added 1 commit 2024-03-21 20:57:41 +01:00
Member

More recent: #119704

More recent: #119704
Author
Member

This approach appears to be a dead end.

As mentioned in ED_object_editmode_exit_multi, "Currently multiple objects sharing a mesh being in edit-mode at once isn't supported, see: #86767." This function then simply return if BKE_object_is_in_editmode

So trying to fix this complaint by changing how multi-object editing works is a bit much. #119704 is a much more sensible approach. Closing this.

This approach appears to be a dead end. As mentioned in `ED_object_editmode_exit_multi`, "Currently multiple objects sharing a mesh being in edit-mode at once isn't supported, see: #86767." This function then simply return if `BKE_object_is_in_editmode` So trying to fix this complaint by changing how multi-object editing works is a bit much. #119704 is a much more sensible approach. Closing this.
Harley Acheson closed this pull request 2024-03-22 16:05:34 +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
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#119759
No description provided.