Fix T45823: PSD files save as JPG without warning

Don't allow image save (which overwrites without asking),
unless the input format can be written to.
This commit is contained in:
Campbell Barton 2015-08-24 21:31:41 +10:00
parent aac6ee6b87
commit 70b7dc993e

@ -176,6 +176,14 @@ static int image_not_packed_poll(bContext *C)
return false;
}
static bool imbuf_format_writeable(const ImBuf *ibuf)
{
ImageFormatData im_format;
ImbFormatOptions options_dummy;
BKE_imbuf_to_image_format(&im_format, ibuf);
return (BKE_image_imtype_to_ftype(im_format.imtype, &options_dummy) == ibuf->ftype);
}
static int space_image_file_exists_poll(bContext *C)
{
if (space_image_buffer_exists_poll(C)) {
@ -197,6 +205,9 @@ static int space_image_file_exists_poll(bContext *C)
else if (!BLI_file_is_writable(name)) {
CTX_wm_operator_poll_msg_set(C, "image path can't be written to");
}
else if (!imbuf_format_writeable(ibuf)) {
CTX_wm_operator_poll_msg_set(C, "image format is read-only");
}
else {
ret = true;
}