LibOverride: Fix resync process no properly tagging newly used linked data as directly linked.
LibOverride resync process would not properly 'make local' newly created overrides (copied from their linked reference). The main consequence was that some linked data used by these new liboverrides would not be properly tagged as directly linked. While this would not be an issue in current codebase, this was breaking upcomming readfile undo refactor, since some linked data did not get their local 'placeholder reference' data written in memfile blendfiles. NOTE: this is more of a quick fix, whole handling of library data in complex copying cases like that need some more general work, see #107848 and #107847.
This commit is contained in:
@@ -67,6 +67,8 @@
|
||||
|
||||
#include "atomic_ops.h"
|
||||
|
||||
#include "lib_intern.h"
|
||||
|
||||
//#define DEBUG_TIME
|
||||
|
||||
#ifdef DEBUG_TIME
|
||||
@@ -439,7 +441,7 @@ void BKE_lib_id_expand_local(Main *bmain, ID *id, const int flags)
|
||||
/**
|
||||
* Ensure new (copied) ID is fully made local.
|
||||
*/
|
||||
static void lib_id_copy_ensure_local(Main *bmain, const ID *old_id, ID *new_id, const int flags)
|
||||
void lib_id_copy_ensure_local(Main *bmain, const ID *old_id, ID *new_id, const int flags)
|
||||
{
|
||||
if (ID_IS_LINKED(old_id)) {
|
||||
BKE_lib_id_expand_local(bmain, new_id, flags);
|
||||
|
||||
@@ -7,6 +7,24 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BKE_lib_remap.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern BKE_library_free_notifier_reference_cb free_notifier_reference_cb;
|
||||
|
||||
extern BKE_library_remap_editor_id_reference_cb remap_editor_id_reference_cb;
|
||||
|
||||
struct ID;
|
||||
struct Main;
|
||||
|
||||
void lib_id_copy_ensure_local(struct Main *bmain,
|
||||
const struct ID *old_id,
|
||||
struct ID *new_id,
|
||||
const int flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -61,6 +61,8 @@
|
||||
|
||||
#include "atomic_ops.h"
|
||||
|
||||
#include "lib_intern.h"
|
||||
|
||||
#define OVERRIDE_AUTO_CHECK_DELAY 0.2 /* 200ms between auto-override checks. */
|
||||
//#define DEBUG_OVERRIDE_TIMEIT
|
||||
|
||||
@@ -277,9 +279,11 @@ static ID *lib_override_library_create_from(Main *bmain,
|
||||
id_us_min(local_id);
|
||||
|
||||
/* TODO: Handle this properly in LIB_NO_MAIN case as well (i.e. resync case). Or offload to
|
||||
* generic ID copy code? */
|
||||
if ((lib_id_copy_flags & LIB_ID_CREATE_NO_MAIN) == 0) {
|
||||
local_id->lib = owner_library;
|
||||
* generic ID copy code? Would probably be better to have a version of #BKE_id_copy_ex that takes
|
||||
* an extra `target_lib` parameter. */
|
||||
local_id->lib = owner_library;
|
||||
if ((lib_id_copy_flags & LIB_ID_CREATE_NO_MAIN) != 0 && owner_library == nullptr) {
|
||||
lib_id_copy_ensure_local(bmain, reference_id, local_id, 0);
|
||||
}
|
||||
|
||||
BKE_lib_override_library_init(local_id, reference_id);
|
||||
|
||||
Reference in New Issue
Block a user