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/windowmanager | |
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/windowmanager')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 13 |
2 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 9d8f68115cf..38f26897998 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -597,7 +597,9 @@ static int wm_operator_exec(bContext *C, wmOperator *op, int repeat) } -/* for running operators with frozen context (modal handlers, menus) */ +/* for running operators with frozen context (modal handlers, menus) + * + * warning: do not use this within an operator to call its self! [#29537] */ int WM_operator_call(bContext *C, wmOperator *op) { return wm_operator_exec(C, op, 0); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 31d276fee01..fb375f1d61f 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2003,6 +2003,7 @@ static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED( { char name[FILE_MAX]; int check_existing=1; + int ret; /* cancel if no active window */ if (CTX_wm_window(C) == NULL) @@ -2027,16 +2028,20 @@ static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED( check_existing = 0; if (G.save_over) { - if (check_existing) + if (check_existing && BLI_exists(name)) { uiPupMenuSaveOver(C, op, name); + ret= OPERATOR_RUNNING_MODAL; + } else { - wm_save_as_mainfile_exec(C, op); + ret= wm_save_as_mainfile_exec(C, op); } - } else { + } + else { WM_event_add_fileselect(C, op); + ret= OPERATOR_RUNNING_MODAL; } - return OPERATOR_RUNNING_MODAL; + return ret; } static void WM_OT_save_mainfile(wmOperatorType *ot) |