pass report list along to BLO_blendhandle_from_file(), avoid unlikely crash in the append operator.
This commit is contained in:
@@ -120,11 +120,13 @@ BLO_blendfiledata_free(
|
||||
* Open a blendhandle from a file path.
|
||||
*
|
||||
* @param file The file path to open.
|
||||
* @param reports Report errors in opening the file (can be NULL).
|
||||
* @return A handle on success, or NULL on failure.
|
||||
*/
|
||||
BlendHandle*
|
||||
BLO_blendhandle_from_file(
|
||||
char *file);
|
||||
char *file,
|
||||
struct ReportList *reports);
|
||||
|
||||
/**
|
||||
* Open a blendhandle from memory.
|
||||
|
||||
@@ -75,11 +75,11 @@ void BLO_blendhandle_print_sizes(BlendHandle *, void *);
|
||||
|
||||
/* Access routines used by filesel. */
|
||||
|
||||
BlendHandle *BLO_blendhandle_from_file(char *file)
|
||||
BlendHandle *BLO_blendhandle_from_file(char *file, ReportList *reports)
|
||||
{
|
||||
BlendHandle *bh;
|
||||
|
||||
bh= (BlendHandle*)blo_openblenderfile(file, NULL);
|
||||
bh= (BlendHandle*)blo_openblenderfile(file, reports);
|
||||
|
||||
return bh;
|
||||
}
|
||||
|
||||
@@ -986,7 +986,7 @@ void filelist_from_library(struct FileList* filelist)
|
||||
/* there we go */
|
||||
/* for the time being only read filedata when libfiledata==0 */
|
||||
if (filelist->libfiledata == NULL) {
|
||||
filelist->libfiledata= BLO_blendhandle_from_file(dir);
|
||||
filelist->libfiledata= BLO_blendhandle_from_file(dir, NULL);
|
||||
if(filelist->libfiledata == NULL) return;
|
||||
}
|
||||
|
||||
@@ -1000,7 +1000,7 @@ void filelist_from_library(struct FileList* filelist)
|
||||
names= BLO_blendhandle_get_datablock_names(filelist->libfiledata, idcode, &nnames);
|
||||
/* ugh, no rewind, need to reopen */
|
||||
BLO_blendhandle_close(filelist->libfiledata);
|
||||
filelist->libfiledata= BLO_blendhandle_from_file(dir);
|
||||
filelist->libfiledata= BLO_blendhandle_from_file(dir, NULL);
|
||||
|
||||
} else {
|
||||
names= BLO_blendhandle_get_linkable_groups(filelist->libfiledata);
|
||||
|
||||
@@ -1548,12 +1548,23 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
bh = BLO_blendhandle_from_file(libname, op->reports);
|
||||
|
||||
if(bh == NULL) {
|
||||
/* unlikely since we just browsed it, but possible
|
||||
* error reports will have been made by BLO_blendhandle_from_file() */
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
||||
/* from here down, no error returns */
|
||||
|
||||
idcode = BKE_idcode_from_name(group);
|
||||
|
||||
/* now we have or selected, or an indicated file */
|
||||
if(RNA_boolean_get(op->ptr, "autoselect"))
|
||||
scene_deselect_all(scene);
|
||||
|
||||
bh = BLO_blendhandle_from_file(libname);
|
||||
idcode = BKE_idcode_from_name(group);
|
||||
|
||||
flag = wm_link_append_flag(op);
|
||||
|
||||
|
||||
@@ -942,7 +942,7 @@ bool KX_BlenderSceneConverter::LinkBlendFileMemory(void *data, int length, const
|
||||
|
||||
bool KX_BlenderSceneConverter::LinkBlendFilePath(const char *path, char *group, KX_Scene *scene_merge, char **err_str)
|
||||
{
|
||||
BlendHandle *bpy_openlib = BLO_blendhandle_from_file( (char *)path );
|
||||
BlendHandle *bpy_openlib = BLO_blendhandle_from_file((char *)path, NULL);
|
||||
|
||||
// Error checking is done in LinkBlendFile
|
||||
return LinkBlendFile(bpy_openlib, path, group, scene_merge, err_str);
|
||||
|
||||
Reference in New Issue
Block a user