Commit Graph

15 Commits

Author SHA1 Message Date
Bastien Montagne 8fbbd69946 Fix T92629: Crash on mesh separate after rB43bc494892c3.
rB43bc494892c3 switched `BKE_libblock_relink_to_newid` to use new ID
remapping and libquery code.

However, that new code does protect by default against remapping an
objects's data pointer when that object is in Edit mode, since this is
not a behavior that generic BKE code can handle (due to required editing
data for most obdata types when in edit mode).

So specific code that does create new IDs and need remapping in Edit
mode has to pass specific exception flags to remaping code.

This commit adds those remapping flags to `BKE_libblock_relink_to_newid`
and add said exception flag to the remapping call from
`ED_object_add_duplicate` when the object is in edit mode.
2021-11-01 15:46:28 +01:00
Bastien Montagne e85e126e3f IDRemap: Add option to force remapping obdata in edit mode.
In theory we should never allow remapping of Objects' obdata ID pointer
when the object is in Edit mode. But there are some cases were this is
needed, so adding yet another exception option to remapping flags.

Preliminary change to fix T92629.
2021-11-01 15:46:28 +01:00
Bastien Montagne 43bc494892 IDManagement: Remove deprecated `BKE_libblock_relink_to_newid` usages.
Move all usages to new `BKE_libblock_relink_to_newid_new`, and rename
that one to `BKE_libblock_relink_to_newid`.

Fix T91413.
2021-10-29 10:45:48 +02:00
Bastien Montagne cddb792021 ID management: Add new version of `relink_to_newid` using proper new remapping code.
Current `BKE_libblock_relink_to_newid` is using its own simplistic,
limited and not really correct version of ID remapping.

While doing a full replacement would have been ideal, this is
risky/time-constrained for Blender 3.0 release, so for now we'll have
both versions co-existing.
2021-09-14 17:49:35 +02:00
Campbell Barton 9b89de2571 Cleanup: consistent use of tags: NOTE/TODO/FIXME/XXX
Also use doxy style function reference `#` prefix chars when
referencing identifiers.
2021-07-04 00:43:40 +10:00
Bastien Montagne 6cbe5dd1c3 ID management: remapping: add flag to enforce refcounting handling.
While indeally we should only skip refcounting when relevant tag is set,
doing this in remapping code is too risky for now.

Related to previous commit and T88555.
2021-05-26 17:05:01 +02:00
Bastien Montagne 4781ab0969 IDRemap: Add option to also remap internal runtime ID pointers.
In some cases (advanced, low-level), we also want to remap pointers like
`ID.newid` or `ID.orig_id`.

Only known case currently is `id_delete`, to avoid leaving potential access to freed memory. See next commit and T86501.
2021-03-12 09:46:11 +01:00
Campbell Barton 2cc5af9c55 Fix T86431: Keep memory location of the window manager on file load
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.

Reviewed By: mont29

Ref D10690
2021-03-12 00:40:52 +11:00
Campbell Barton b347c4e9ca Cleanup: remove redundant struct declarations 2020-12-16 16:25:56 +11:00
Jacques Lucke 91694b9b58 Code Style: use "#pragma once" in source directory
This replaces header include guards with `#pragma once`.
A couple of include guards are not removed yet (e.g. `__RNA_TYPES_H__`),
because they are used in other places.

This patch has been generated by P1561 followed by `make format`.

Differential Revision: https://developer.blender.org/D8466
2020-08-07 09:50:34 +02:00
Jacques Lucke 6f985574b7 Cleanup: take includes out of 'extern "C"' blocks
Surrounding includes with an 'extern "C"' block is not necessary anymore.
Also that made it harder to add any C++ code to some headers, or include headers
that have "optional" C++ code like `MEM_guardedalloc.h`.

I tested compilation on linux and windows (and got help from @LazyDodo).
If this still breaks compilation due to some linker error, the header containing
the symbol in question is probably missing an 'extern "C"' block.

Differential Revision: https://developer.blender.org/D7653
2020-05-08 18:22:41 +02:00
Bastien Montagne 0de5156a24 Cleanup: WindowManager: Move to IDTypeInfo and remove unused WM API.
Getting rid of one static 'registered' callback in BKE, yeah!
2020-03-09 12:49:04 +01:00
Bastien Montagne ddad044cfe Fix mismatch in BKE headers' multi-include safeguards naming.
Forgot to update those in recent `BKE_lib_` files renames.
2020-02-10 16:54:24 +01:00
Bastien Montagne cd48b132ff Cleanup: Add basic doc about each `BKE_main` and `BKE_lib` files.
Including expected prefixes for functions in those files.

Part of T72604.
2020-02-10 15:05:54 +01:00
Bastien Montagne 56116bbdf4 Cleanup/refactor: Rename `BKE_library` files to `BKE_lib`.
Note that `BKE_library.h`/`library.c` were renamed to
`BKE_lib_id.h`/`lib_id.c` to avoid having a too generic name here.

Part of T72604.
2020-02-10 13:00:42 +01:00