From 3e7ad0e2714009509004669d8da8ea8c71fa0d04 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 12 Dec 2011 18:06:36 +0000 Subject: fix [#29537] file/save crashes when target path isnt found bug was that uiPupMenuSaveOver(...) could run the WM API call function which freed the operator, within the low level invoke function which kept using the freed memory. Changed uiPupMenuSaveOver(...) to only show a popup so the caller needs to check if the file exists and should be immediately written (which was done everywhere except for blend saving anyway). * added note that operators invoke/exec funcs cant call WM_operator_call(...) on themselves, ends up using freed memory. * added BLI_is_file(path), checks the file exists and isnt a directory. --- source/blender/blenlib/intern/storage.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/blenlib/intern') diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 1ef254d355f..001b191155d 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -471,6 +471,12 @@ int BLI_is_dir(const char *file) return S_ISDIR(BLI_exists(file)); } +int BLI_is_file(const char *path) +{ + int mode= BLI_exists(path); + return (mode && !S_ISDIR(mode)); +} + LinkNode *BLI_file_read_as_lines(const char *name) { FILE *fp= fopen(name, "r"); -- cgit v1.2.3