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
This commit is contained in:
Philipp Oeser
2024-05-22 14:50:25 +02:00
committed by Philipp Oeser
parent 692af3f9aa
commit c6aa1fec2b
2 changed files with 17 additions and 8 deletions

View File

@@ -114,13 +114,13 @@ int BKE_packedfile_count_all(Main *bmain)
for (ima = static_cast<Image *>(bmain->images.first); ima;
ima = static_cast<Image *>(ima->id.next))
{
if (BKE_image_has_packedfile(ima)) {
if (BKE_image_has_packedfile(ima) && !ID_IS_LINKED(ima)) {
count++;
}
}
for (vf = static_cast<VFont *>(bmain->fonts.first); vf; vf = static_cast<VFont *>(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<bSound *>(bmain->sounds.first); sound;
sound = static_cast<bSound *>(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<Volume *>(bmain->volumes.first); volume;
volume = static_cast<Volume *>(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<Image *>(bmain->images.first); ima;
ima = static_cast<Image *>(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<VFont *>(bmain->fonts.first); vf; vf = static_cast<VFont *>(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<bSound *>(bmain->sounds.first); sound;
sound = static_cast<bSound *>(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<Volume *>(bmain->volumes.first); volume;
volume = static_cast<Volume *>(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;

View File

@@ -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");