From c6aa1fec2bc439ee8eeb297202890fdd77245f01 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 22 May 2024 14:50:25 +0200 Subject: [PATCH] Fix: Dont unpack resources that are packed in linked files These remain linked, so data remains to be read/loaded from the packed version from the library (making this a useless and wasteful duplication, also changes could be perceived as lost). Tooltip was also reading "Unpack all files packed **into this .blend** to external ones", so that bring it in line with the tooltip. This came up in #122033 Pull Request: https://projects.blender.org/blender/blender/pulls/122092 --- .../blender/blenkernel/intern/packedFile.cc | 21 ++++++++++++------- .../templates/interface_templates.cc | 4 ++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/intern/packedFile.cc b/source/blender/blenkernel/intern/packedFile.cc index d52b43e761c..75c3978e997 100644 --- a/source/blender/blenkernel/intern/packedFile.cc +++ b/source/blender/blenkernel/intern/packedFile.cc @@ -114,13 +114,13 @@ int BKE_packedfile_count_all(Main *bmain) for (ima = static_cast(bmain->images.first); ima; ima = static_cast(ima->id.next)) { - if (BKE_image_has_packedfile(ima)) { + if (BKE_image_has_packedfile(ima) && !ID_IS_LINKED(ima)) { count++; } } for (vf = static_cast(bmain->fonts.first); vf; vf = static_cast(vf->id.next)) { - if (vf->packedfile) { + if (vf->packedfile && !ID_IS_LINKED(vf)) { count++; } } @@ -128,7 +128,7 @@ int BKE_packedfile_count_all(Main *bmain) for (sound = static_cast(bmain->sounds.first); sound; sound = static_cast(sound->id.next)) { - if (sound->packedfile) { + if (sound->packedfile && !ID_IS_LINKED(sound)) { count++; } } @@ -136,7 +136,7 @@ int BKE_packedfile_count_all(Main *bmain) for (volume = static_cast(bmain->volumes.first); volume; volume = static_cast(volume->id.next)) { - if (volume->packedfile) { + if (volume->packedfile && !ID_IS_LINKED(volume)) { count++; } } @@ -782,13 +782,13 @@ void BKE_packedfile_unpack_all(Main *bmain, ReportList *reports, enum ePF_FileSt for (ima = static_cast(bmain->images.first); ima; ima = static_cast(ima->id.next)) { - if (BKE_image_has_packedfile(ima)) { + if (BKE_image_has_packedfile(ima) && !ID_IS_LINKED(ima)) { BKE_packedfile_unpack_image(bmain, reports, ima, how); } } for (vf = static_cast(bmain->fonts.first); vf; vf = static_cast(vf->id.next)) { - if (vf->packedfile) { + if (vf->packedfile && !ID_IS_LINKED(vf)) { BKE_packedfile_unpack_vfont(bmain, reports, vf, how); } } @@ -796,7 +796,7 @@ void BKE_packedfile_unpack_all(Main *bmain, ReportList *reports, enum ePF_FileSt for (sound = static_cast(bmain->sounds.first); sound; sound = static_cast(sound->id.next)) { - if (sound->packedfile) { + if (sound->packedfile && !ID_IS_LINKED(sound)) { BKE_packedfile_unpack_sound(bmain, reports, sound, how); } } @@ -804,7 +804,7 @@ void BKE_packedfile_unpack_all(Main *bmain, ReportList *reports, enum ePF_FileSt for (volume = static_cast(bmain->volumes.first); volume; volume = static_cast(volume->id.next)) { - if (volume->packedfile) { + if (volume->packedfile && !ID_IS_LINKED(volume)) { BKE_packedfile_unpack_volume(bmain, reports, volume, how); } } @@ -841,6 +841,11 @@ bool BKE_packedfile_id_check(const ID *id) void BKE_packedfile_id_unpack(Main *bmain, ID *id, ReportList *reports, enum ePF_FileStatus how) { + /* Dont unpack resources that are packed in linked IDs. */ + if (ID_IS_LINKED(id)) { + return; + } + switch (GS(id->name)) { case ID_IM: { Image *ima = (Image *)id; diff --git a/source/blender/editors/interface/templates/interface_templates.cc b/source/blender/editors/interface/templates/interface_templates.cc index 33b70afbd6b..3f97053d063 100644 --- a/source/blender/editors/interface/templates/interface_templates.cc +++ b/source/blender/editors/interface/templates/interface_templates.cc @@ -1536,6 +1536,10 @@ static void template_ID(const bContext *C, RNA_string_set(but->opptr, "id_name", id->name + 2); RNA_int_set(but->opptr, "id_type", GS(id->name)); + + if (ID_IS_LINKED(id)) { + UI_but_flag_enable(but, UI_BUT_DISABLED); + } } else if (flag & UI_ID_OPEN) { const char *button_text = (id) ? "" : IFACE_("Open");