Fix #108763: temp_override to consider context's screen #114269
No reviewers
Labels
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#114269
Loading…
Reference in New Issue
No description provided.
Delete Branch "Andrej730/blender:screen_temp_override"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Previously it was checking the actually active screen - it was leading to the issue where it's no longer possible to override
context.screen
(#108763) which was possible with old context override method.Issue mechanics - when operator is called with
area
andscreen
overriden it throwsTypeError: Area not found in screen
since it'sarea
do not belong to the currently activescreen
.screen
override is required if you want to use some operator that's using area that's not available on the current screen. Most important case for me personally isbpy.ops.node.clipboard_copy
because that's basically the only way to copy nodes from one shader tree to another.temp_override to consider context's screen #108763to Fix #108763: temp_override to consider context's screenWe should be able to support something like this but there is an aspect of this patch which I'm not so keen on.
I'm concerned that setting the screen, leaves the screen returned by
WM_window_get_active_screen
unchanged. Since the screen returned by the window is used quite a lot, I think it's error prone that Blender is left (even temporarily) in a state where only some functions will return the overridden screen.Bigger picture, my aim with the temporary overrides was to ensure an inconsistent state is never allowed (so an active area is always part of the screen for e.g. so states that are likely to confuse lower level logic - which may crash, are never allowed).
This PR allows to set an active screen which isn't used by the current window which violates this principle.
Of course and argument can always be made that in this particular case it's OK... but I'm wary of allowing the windows screen and the contexts screen to get out of sync.
A solution could be to temporarily override the screen used by the active window. This also has some complications* but in general I think it's going to work predictably and cause the least amount of problems long term.
Before requesting changes to this PR it would be good to get a second opinion (maybe @mont29 ?).
* The main complication as far as I can see is when the overriding screen is already used by a window. Currently it's assumed each screen is only ever instanced once, so we need to check if it's acceptable to make a temporary exception to this rule. An alternative could be to set that other window using the requested screen active.
I would indeed not allow a mismatch between the window and the screen in the context passed to operators and underlying code.
Overriding the active screen of the active window (or making another window active if given screen is already used by it) sounds like a reasonable idea to me.
Found another issue with the first approach - getting context items like
context.active_object
(context
doesn't have attributeactive_object
...) was resulting in errors sincectx_data_get
is usingscreen->context
to get some context items andscreen
is not active, thenscreen->context
is null, resulting in those errors.Added changes. I've used similar approach with
ContextStore ctx_temp
- if the window's screen doesn't match the screen from thetemp_override
, then it switches the screen and switches it back onbpy_rna_context_temp_override_exit
. It's also considering that if the temp_override.window's screen is matching temp_override.screen already then there is no need to switch it back later since windows screens basically were untouched.Initially I thought I could just change active screen with something like
WM_window_set_active_screen
but since screens are connected to their workspaces I've switched the workspaces.I've run some tests I've had issues with before:
tests code in python
Not full review, this seems the right direction though.
New screen logic should be added between
window
&area
logic so the order is always:window -> screen -> area -> region
.@ -83,3 +86,3 @@
self->ctx_init.region_is_set = (self->ctx_init.region != region);
bScreen *screen = win ? WM_window_get_active_screen(win) : nullptr;
// overridding screen is a bit different since
*picky* use C-style comments, full sentences.
Fixed.
@ -391,2 +423,4 @@
ctx_temp.region_is_set = true;
}
if (params.screen.ptr != nullptr) {
ctx_temp.screen = static_cast<bScreen *>(params.screen.ptr->data);
Temporary screens
screen->temp != 0
screens should fail with an exception. Perhaps they could be supported but for this patch it's simplest not to.Added an exception.
Rearranged the code a bit but
self->ctx_init.screen = WM_window_get_active_screen(win);
is still not part of otherself->ctx_init.___ = ___
block since it's need to know whatwin
is going to be used.:If window and screen are overridden then we're possibly changing workspace for some other window, so we'll need to store the original screen for that particular window in
self->ctx_init.screen
, therefore we need to know the exact used window first.@ideasman42 anything to change or looks good?
Committed
6af92e1360
with some edits.@ideasman42 hi! thanks for merging this!
Any ideas of good place in tests/python to add some tests for
context.temp_override
?And I think I've found a bug - it occurs if we override both window and screen and overridden window's screen is never switched back. Reported it separately - #115937
@Andrej730 better to report the bug as a new Bug Report (while mentioning this pull request #114269), so it can be better processed
Pull request closed