Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2015-05-23 00:28:41 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-05-23 00:28:41 +0300
commit25f5d2b4d7e83f52807be13d255cfde2ea51d8ee (patch)
tree553c9239046f62cc91b8ad7f8731c484647ebaab
parente529882be0752cdfd4fcf2f6b6bc06bcb44947af (diff)
Fix (unreported) broken RNA Image pack handling since multiview merge.
Was breaking loading of embedded FBX images (among other things, most likely).
-rw-r--r--source/blender/blenkernel/BKE_image.h1
-rw-r--r--source/blender/blenkernel/intern/image.c16
-rw-r--r--source/blender/editors/space_node/drawnode.c5
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c20
4 files changed, 31 insertions, 11 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index a49301eebee..6b80e6b310f 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -229,6 +229,7 @@ void BKE_image_all_free_anim_ibufs(int except_frame);
void BKE_image_memorypack(struct Image *ima);
void BKE_image_packfiles(struct ReportList *reports, struct Image *ima, const char *basepath);
+void BKE_image_packfiles_from_mem(struct ReportList *reports, struct Image *ima, char *data, const size_t data_len);
/* prints memory statistics for images */
void BKE_image_print_memlist(void);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index f6513a3e016..c6d302ee15e 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -75,6 +75,7 @@
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_packedFile.h"
+#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_node.h"
#include "BKE_sequencer.h" /* seq_foreground_frame_get() */
@@ -1030,6 +1031,21 @@ void BKE_image_packfiles(ReportList *reports, Image *ima, const char *basepath)
}
}
+void BKE_image_packfiles_from_mem(ReportList *reports, Image *ima, char *data, const size_t data_len)
+{
+ const size_t totfiles = image_num_files(ima);
+
+ if (totfiles != 1) {
+ BKE_report(reports, RPT_ERROR, "Cannot pack multiview images from raw data currently...");
+ }
+ else {
+ ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), __func__);
+ BLI_addtail(&ima->packedfiles, imapf);
+ imapf->packedfile = newPackedFileMemory(data, data_len);
+ BLI_strncpy(imapf->filepath, ima->name, sizeof(imapf->filepath));
+ }
+}
+
void BKE_image_tag_time(Image *ima)
{
ima->lastused = PIL_check_seconds_timer_i();
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index d08a8bacd29..648c93ff20c 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -864,14 +864,15 @@ static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, P
if (!(ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER))) {
uiLayout *row = uiLayoutRow(layout, true);
+ const bool is_packed = BKE_image_has_packedfile(ima);
- if (ima->packedfile)
+ if (is_packed)
uiItemO(row, "", ICON_PACKAGE, "image.unpack");
else
uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack");
row = uiLayoutRow(row, true);
- uiLayoutSetEnabled(row, ima->packedfile == NULL);
+ uiLayoutSetEnabled(row, !is_packed);
uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE);
uiItemO(row, "", ICON_FILE_REFRESH, "image.reload");
}
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index 47be7bec432..945359515ab 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -117,9 +117,14 @@ static void rna_Image_save(Image *image, Main *bmain, bContext *C, ReportList *r
BLI_strncpy(filename, image->name, sizeof(filename));
BLI_path_abs(filename, ID_BLEND_PATH(bmain, &image->id));
- if (image->packedfile) {
- if (writePackedFile(reports, image->name, image->packedfile, 0) != RET_OK) {
- BKE_reportf(reports, RPT_ERROR, "Image '%s' could not save packed file to '%s'", image->id.name + 2, image->name);
+ if (BKE_image_has_packedfile(image)) {
+ ImagePackedFile *imapf;
+
+ for (imapf = image->packedfiles.first; imapf; imapf = imapf->next) {
+ if (writePackedFile(reports, imapf->filepath, imapf->packedfile, 0) != RET_OK) {
+ BKE_reportf(reports, RPT_ERROR, "Image '%s' could not save packed file to '%s'",
+ image->id.name + 2, imapf->filepath);
+ }
}
}
else if (IMB_saveiff(ibuf, filename, ibuf->flags)) {
@@ -154,17 +159,14 @@ static void rna_Image_pack(
BKE_report(reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG");
}
else {
- if (image->packedfile) {
- freePackedFile(image->packedfile);
- image->packedfile = NULL;
- }
+ BKE_image_free_packedfiles(image);
if (as_png) {
BKE_image_memorypack(image);
}
else if (data) {
char *data_dup = MEM_mallocN(sizeof(*data_dup) * (size_t)data_len, __func__);
memcpy(data_dup, data, (size_t)data_len);
- image->packedfile = newPackedFileMemory(data_dup, data_len);
+ BKE_image_packfiles_from_mem(reports, image, data_dup, (size_t)data_len);
}
else {
BKE_image_packfiles(reports, image, ID_BLEND_PATH(bmain, &image->id));
@@ -177,7 +179,7 @@ static void rna_Image_pack(
static void rna_Image_unpack(Image *image, ReportList *reports, int method)
{
- if (!image->packedfile) {
+ if (!BKE_image_has_packedfile(image)) {
BKE_report(reports, RPT_ERROR, "Image not packed");
}
else if (BKE_image_is_animated(image)) {