Fix #112767: Outliner unlink operation fails to unlink from scene #112955

Merged
Pratik Borhade merged 4 commits from PratikPB2123/blender:112767-outliner-scene-unlink into main 2023-11-23 14:49:26 +01:00
Member

When in scene mode, operation searches the object in master collection
to unlink. But object can be in any collection. So iterate through all
collections present in scene to unlink the object

When in scene mode, operation searches the object in master collection to unlink. But object can be in any collection. So iterate through all collections present in scene to unlink the object
Pratik Borhade added 1 commit 2023-09-27 15:15:52 +02:00
f468105a90 Fix #112767: Outliner unlink operation fails to unlink from scene
When in scene mode, operation searches the object in master collection
to unlink. but object can be in any collection. So iterate thorugh all
collections present in scene to unlink the object
Pratik Borhade requested review from Harley Acheson 2023-09-27 15:16:08 +02:00
Pratik Borhade requested review from Julian Eisel 2023-09-27 15:16:08 +02:00
Pratik Borhade added the
Module
User Interface
label 2023-09-27 15:16:18 +02:00
Brecht Van Lommel changed title from Fix #112767: Outliner unlink operation fails to unlink from scene to Fix #112767: Outliner unlink operation fails to unlink from scene 2023-09-27 16:01:23 +02:00
brecht changed target branch from main to blender-v4.0-release 2023-09-27 16:01:24 +02:00
Brecht Van Lommel changed title from Fix #112767: Outliner unlink operation fails to unlink from scene to Fix #112767: Outliner unlink operation fails to unlink from scene 2023-09-27 16:06:44 +02:00
brecht changed target branch from blender-v4.0-release to main 2023-09-27 16:06:45 +02:00

Reminder, bugfixes like this should go to the 4.0 branch. But just switching in Gitea isn't enough as the commit needs to be rebased also.

Reminder, bugfixes like this should go to the 4.0 branch. But just switching in Gitea isn't enough as the commit needs to be rebased also.
Author
Member

@brecht , sure. I'll rebase the branch once PR is approved :)

Maintaining working branch with "main" seems handy

@brecht , sure. I'll rebase the branch once PR is approved :) Maintaining working branch with "main" seems handy
Julian Eisel requested review from Bastien Montagne 2023-11-10 11:55:15 +01:00
Julian Eisel approved these changes 2023-11-10 11:59:35 +01:00
Julian Eisel left a comment
Member

Seems correct, but would like somebody like Bastien or Brecht to double check.

Seems correct, but would like somebody like Bastien or Brecht to double check.
Bastien Montagne requested changes 2023-11-10 13:04:02 +01:00
@ -467,3 +467,2 @@
Scene *scene = (Scene *)tsep->id;
Collection *parent = scene->master_collection;
BKE_collection_object_remove(bmain, parent, ob, true);
FOREACH_SCENE_COLLECTION_BEGIN (scene, collection) {

Would need a comment here, since this only works because the only case when the parent item is a Scene is in the Scene view of the Outliner. in ViewLayer view, the parent of an object item is always a collection (normal one, or the Scene's master collection).

In fact, would also be good to have an assert that this branch is only executed from an Outliner in Scene view...

Would need a comment here, since this only works because the only case when the parent item is a Scene is in the `Scene` view of the Outliner. in `ViewLayer` view, the parent of an object item is always a collection (normal one, or the Scene's master collection). In fact, would also be good to have an assert that this branch is only executed from an Outliner in `Scene` view...
Author
Member

@mont29 , I think the condition else if (GS(tsep->id->name) == ID_SCE) { itself suggests we're in outliner scene view.
Because in scene view, parent of selected data references to scene itself.
If object is child of some object then we're finding parent scene/collection to unlink the object from: see

@mont29 , I think the condition `else if (GS(tsep->id->name) == ID_SCE) {` itself suggests we're in outliner `scene` view. Because in scene view, parent of selected data references to `scene` itself. If object is child of some object then we're finding parent scene/collection to unlink the object from: [see](https://projects.blender.org/blender/blender/src/branch/main/source/blender/editors/space_outliner/outliner_tools.cc#L443)

What I am saying is that this code makes certain assumptions about the context in which it is executed, and that these assumptions should be both documented as a comment, and preferably validated with some assert

I think the condition else if (GS(tsep->id->name) == ID_SCE) { itself suggests we're in outliner Scene view.

That is exactly what I am asking you to explain in the comment. Because there is nothing 'obvious' about that assumption, and while correct in current code, it may very well become wrong in the future, causing the code to have an unexpected/buggy behavior.

What I am saying is that this code makes certain assumptions about the context in which it is executed, and that these assumptions should be both documented as a comment, and preferably validated with some `assert` > I think the condition `else if (GS(tsep->id->name) == ID_SCE) {` itself suggests we're in outliner `Scene` view. That is exactly what I am asking you to explain in the comment. Because there is nothing 'obvious' about that assumption, and while correct in current code, it may very well become wrong in the future, causing the code to have an unexpected/buggy behavior.
Author
Member

Ok, thanks for clarifying 😅
Updated, I hope this one liner comment is sufficient :)

Ok, thanks for clarifying 😅 Updated, I hope this one liner comment is sufficient :)
Pratik Borhade added 2 commits 2023-11-23 05:02:36 +01:00
Bastien Montagne approved these changes 2023-11-23 10:38:51 +01:00
Bastien Montagne left a comment
Owner

Thanks, yes it's essentially good to go now.

Following points can be addressed before final commit, no need for extra review for them.

Thanks, yes it's essentially good to go now. Following points can be addressed before final commit, no need for extra review for them.
@ -473,9 +473,17 @@ static void unlink_object_fn(bContext *C,
DEG_relations_tag_update(bmain);
}
else if (GS(tsep->id->name) == ID_SCE) {
/* Following execution is expected to happen in outliner scene view. */

to happen exclusively in the Outliner Scene view

`to happen exclusively in the Outliner Scene view`
@ -474,2 +474,4 @@
}
else if (GS(tsep->id->name) == ID_SCE) {
/* Following execution is expected to happen in outliner scene view. */
SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);

These two lines should be inside a #ifndef NDEBUG block.

These two lines should be inside a `#ifndef NDEBUG` block.
Pratik Borhade added 1 commit 2023-11-23 14:47:23 +01:00
Pratik Borhade merged commit 3dc119a440 into main 2023-11-23 14:49:26 +01:00
Pratik Borhade deleted branch 112767-outliner-scene-unlink 2023-11-23 14:49:28 +01:00
Author
Member

Merged, thanks for reviewing :)

Merged, thanks for reviewing :)
Sign in to join this conversation.
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
4 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#112955
No description provided.