Fix T81656: Crash relocating a linked library into the current .blend

A .blend file cannot use itself as a library.
This is prevented when linking manually, but was still possible when
relocating, which is now prevented.

Maniphest Tasks: T81656

Differential Revision: https://developer.blender.org/D9191
This commit is contained in:
Philipp Oeser 2020-10-13 11:43:32 +02:00
parent 79875e37fe
commit 16289274ed
Notes: blender-bot 2023-09-13 08:48:34 +02:00
Referenced by issue #81656, Crash when trying to make the actual .blend file a relocated linked library into itself
1 changed files with 9 additions and 0 deletions

View File

@ -1057,6 +1057,15 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
return OPERATOR_CANCELLED;
}
if (BLI_path_cmp(BKE_main_blendfile_path(bmain), path) == 0) {
BKE_reportf(op->reports,
RPT_ERROR_INVALID_INPUT,
"Cannot relocate library '%s' to current blend file '%s'",
lib->id.name,
path);
return OPERATOR_CANCELLED;
}
if (BLI_path_cmp(lib->filepath_abs, path) == 0) {
#ifdef PRINT_DEBUG
printf("We are supposed to reload '%s' lib (%d)...\n", lib->filepath, lib->id.us);