Bugfix #4363
In windows, without temp path set, the 'save buffers' render option crashes. I've coded a blenlib BLI_is_writable(char *filename) to check for such cases. This is not much needed in Blender, since the open() command is checked for. However, file saving happens deep inside the C++ exr lib, and it throws an exception crash when a file cannot be written.
This commit is contained in:
@@ -256,7 +256,7 @@ int BLI_exist(char *name);
|
||||
void BLI_recurdir_fileops(char *dirname);
|
||||
int BLI_link(char *file, char *to);
|
||||
int BLI_backup(char *file, char *from, char *to);
|
||||
|
||||
int BLI_is_writable(char *filename);
|
||||
|
||||
/**
|
||||
* @attention Do not confuse with BLI_exist
|
||||
|
||||
@@ -125,6 +125,21 @@ int BLI_gzip(char *from, char *to) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* return 1 when file can be written */
|
||||
int BLI_is_writable(char *filename)
|
||||
{
|
||||
int file;
|
||||
|
||||
file = open(filename, O_BINARY | O_RDWR | O_CREAT | O_TRUNC, 0666);
|
||||
|
||||
if (file < 0)
|
||||
return 0;
|
||||
else {
|
||||
close(file);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
static char str[MAXPATHLEN+12];
|
||||
|
||||
@@ -1102,9 +1102,10 @@ static void threaded_tile_processor(Render *re)
|
||||
|
||||
if(rr->exrhandle) {
|
||||
char str[FILE_MAXDIR+FILE_MAXFILE];
|
||||
render_unique_exr_name(re, str);
|
||||
printf("write exr tmp file, %dx%d, %s\n", rr->rectx, rr->recty, str);
|
||||
|
||||
render_unique_exr_name(re, str);
|
||||
|
||||
printf("write exr tmp file, %dx%d, %s\n", rr->rectx, rr->recty, str);
|
||||
IMB_exrtile_begin_write(rr->exrhandle, str, rr->rectx, rr->recty, rr->rectx/re->xparts, rr->recty/re->yparts);
|
||||
}
|
||||
|
||||
@@ -1721,6 +1722,18 @@ static int is_rendering_allowed(Render *re)
|
||||
}
|
||||
}
|
||||
|
||||
if(re->r.scemode & R_EXR_TILE_FILE) {
|
||||
char str[FILE_MAXDIR+FILE_MAXFILE];
|
||||
|
||||
render_unique_exr_name(re, str);
|
||||
|
||||
if (BLI_is_writable(str)==0) {
|
||||
re->error("Can not save render buffers, check the temp default path");
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(re->r.scemode & R_DOCOMP) {
|
||||
if(re->scene->use_nodes) {
|
||||
bNodeTree *ntree= re->scene->nodetree;
|
||||
|
||||
Reference in New Issue
Block a user