Fix T45059: Image open /w relative paths & anim

- would hang on win32 (checking network share?)
- made the path absolute on all systems
This commit is contained in:
Campbell Barton 2015-06-17 15:57:00 +10:00 committed by Sergey Sharybin
parent ca6e79c226
commit f526f410b2
Notes: blender-bot 2023-02-14 09:00:26 +01:00
Referenced by issue #45059, bug with relative path
1 changed files with 19 additions and 7 deletions

View File

@ -1073,15 +1073,27 @@ static int image_open_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", path);
if (!IMB_isanim(path) && RNA_struct_property_is_set(op->ptr, "files") &&
RNA_struct_property_is_set(op->ptr, "directory"))
if (RNA_struct_property_is_set(op->ptr, "directory") &&
RNA_struct_property_is_set(op->ptr, "files"))
{
ListBase frames;
/* only to pass to imbuf */
char path_full[FILE_MAX];
BLI_strncpy(path_full, path, sizeof(path_full));
BLI_path_abs(path_full, G.main->name);
BLI_listbase_clear(&frames);
image_sequence_get_frames(op->ptr, &frames, path, sizeof(path));
frame_seq_len = image_sequence_get_len(&frames, &frame_ofs);
BLI_freelistN(&frames);
if (!IMB_isanim(path_full)) {
bool was_relative = BLI_path_is_rel(path);
ListBase frames;
BLI_listbase_clear(&frames);
image_sequence_get_frames(op->ptr, &frames, path, sizeof(path));
frame_seq_len = image_sequence_get_len(&frames, &frame_ofs);
BLI_freelistN(&frames);
if (was_relative) {
BLI_path_rel(path, G.main->name);
}
}
}
errno = 0;