Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-12-12 22:06:36 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-12-12 22:06:36 +0400
commit3e7ad0e2714009509004669d8da8ea8c71fa0d04 (patch)
tree9448ca11bb4325aedda01e9aa418b981ebc7d278 /source/blender/editors/interface
parentcd0608aff5958e6fc59aad10730255d3cac48622 (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/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_regions.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 58c3c0130b8..b89a80bb0d7 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -2481,22 +2481,14 @@ void uiPupMenuOkee(bContext *C, const char *opname, const char *str, ...)
va_end(ap);
}
+/* note, only call this is the file exists,
+ * the case where the file does not exist so can be saved without a
+ * popup must be checked for already, since saving from here
+ * will free the operator which will break invoke().
+ * The operator state for this is implicitly OPERATOR_RUNNING_MODAL */
void uiPupMenuSaveOver(bContext *C, wmOperator *op, const char *filename)
{
- size_t len= strlen(filename);
-
- if(len==0)
- return;
-
- if(filename[len-1]=='/' || filename[len-1]=='\\') {
- uiPupMenuError(C, "Cannot overwrite a directory");
- WM_operator_free(op);
- return;
- }
- if(BLI_exists(filename)==0)
- operator_cb(C, op, 1);
- else
- confirm_operator(C, op, "Save Over", filename);
+ confirm_operator(C, op, "Save Over", filename);
}
void uiPupMenuNotice(bContext *C, const char *str, ...)