diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-12-12 22:06:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-12-12 22:06:36 +0400 |
commit | 3e7ad0e2714009509004669d8da8ea8c71fa0d04 (patch) | |
tree | 9448ca11bb4325aedda01e9aa418b981ebc7d278 /source/blender/blenlib | |
parent | cd0608aff5958e6fc59aad10730255d3cac48622 (diff) |
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.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_fileops.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/storage.c | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index 712429716a6..2e8f1a5512e 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -56,6 +56,7 @@ int BLI_create_symlink(const char *path, const char *to); struct direntry; int BLI_is_dir(const char *path); +int BLI_is_file(const char *path); void BLI_dir_create_recursive(const char *dir); double BLI_dir_free_space(const char *dir); char *BLI_current_working_dir(char *dir, const int maxlen); 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"); |