Page MenuHome

Fix T86431: Keep the memory location of the window manager when loading a file
ClosedPublic

Authored by Campbell Barton (campbellbarton) on Mar 11 2021, 3:35 AM.

Details

Summary

Keep the pointer location from the initial window-manager
between file load operations.

This is needed as the Python API may hold references to keymaps for e.g.
which are transferred to the newly loaded window manager, without their PointerRNA.owner_id fields being updated.

Since there is only ever one window manager, keep the memory at the same location so the Python ID pointers stay valid.


Notes

I'm skeptical of including BKE_libblock_remap. while technically correct, it seems like a heavy operation for a case which is doesn't seem useful in practice.

  • As there is only ever one window manager, it doesn't seem useful to reference it from an ID property.
  • References to windowing data aren't reliable, they will be lost when opening with "Load UI" is disabled.
  • Currently support for referencing windowing in IDProperties seems quite untested/buggy, I managed to crash Blender storing a workspace in an ID properties, then removing the workspace - for example. We could consider these bugs to fix, again - it seems a fairly obscure use-case.

An alternative solution to BKE_libblock_remap could be to do-version existing files, removing window-manager (perhaps all windowing ID's) from ID-properties & drivers. So there is no need to check for this case.

Or, this patch could be committed as-is, keeping open the possibility of removing window-manager references in the future.

Diff Detail

Repository
rB Blender
Branch
TEMP-T86431-FIX (branched from master)
Build Status
Buildable 13424
Build 13424: arc lint + arc unit

Event Timeline

Campbell Barton (campbellbarton) requested review of this revision.Mar 11 2021, 3:35 AM
Campbell Barton (campbellbarton) created this revision.
Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)
  • Remove experimental code that shouldn't have been included.
Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)
Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)
Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)

Patch LGTM.

Re remapping and window-related IDs. indeed we may consider forbidding their referencing from any RNA pointer property at some point... But this is rather unrelated to that specific issue, and for now the ID management code is supposed to support references to any type of data-block in a generic way, so would rather fix issues with that first, and keep that consistency behavior for now.

This revision is now accepted and ready to land.Mar 11 2021, 11:33 AM