svn merge ^/trunk/blender -r42564:42586
authorCampbell Barton <ideasman42@gmail.com>
Mon, 12 Dec 2011 21:01:39 +0000 (21:01 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 12 Dec 2011 21:01:39 +0000 (21:01 +0000)
23 files changed:
release/scripts/modules/bpy/path.py
release/scripts/startup/bl_operators/anim.py
release/scripts/startup/bl_operators/clip.py
release/scripts/startup/bl_operators/image.py
release/scripts/startup/bl_operators/wm.py
source/blender/blenlib/BLI_fileops.h
source/blender/blenlib/intern/storage.c
source/blender/editors/animation/keyingsets.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_ops.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/mesh/bmesh_tools.c
source/blender/editors/object/object_hook.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/space_clip/clip_toolbar.c
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_view3d/view3d_toolbar.c
source/blender/editors/util/undo.c
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_actuator.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_operators.c

index 4173d71b39c7dff1b73f7ec19494bfc1f871fa72..98a3c81d65a3bb83f93db7922e7814d909c77b8d 100644 (file)
@@ -54,7 +54,7 @@ def abspath(path, start=None, library=None):
     """
     if path.startswith("//"):
         if library:
-            start = abspath(_os.path.dirname(library.filepath))
+            start = _os.path.dirname(abspath(library.filepath))
         return _os.path.join(_os.path.dirname(_bpy.data.filepath)
                              if start is None else start,
                              path[2:],
index e1d33198142920943646cc502fc0193b8658e63e..01103aede0da17cd322296d34e82cf87b5962195 100644 (file)
@@ -38,7 +38,7 @@ class ANIM_OT_keying_set_export(Operator):
     bl_label = "Export Keying Set..."
 
     filepath = StringProperty(
-            name="File Path",
+            subtype='FILE_PATH',
             )
     filter_folder = BoolProperty(
             name="Filter folders",
index 11d545849ef2855adbecf5daf3ea5ad33466f388..061c66dc1fa23ab0a738e2172ace70cb5f7fd492 100644 (file)
@@ -413,7 +413,12 @@ class CLIP_OT_setup_tracking_scene(Operator):
 
     @staticmethod
     def _setupCamera(context):
+        sc = context.space_data
+        clip = sc.clip
+        tracking = clip.tracking
+
         camob = CLIP_OT_setup_tracking_scene._findOrCreateCamera(context)
+        cam = camob.data
 
         # Remove all constraints to be sure motion is fine
         camob.constraints.clear()
@@ -423,6 +428,9 @@ class CLIP_OT_setup_tracking_scene(Operator):
         con.use_active_clip = True
         con.influence = 1.0
 
+        cam.sensor_width = tracking.camera.sensor_width
+        cam.lens = tracking.camera.focal_length
+
     @staticmethod
     def _setupViewport(context):
         sc = context.space_data
index c97f6eae6c78cc8f7352041b5e54becc21f86865..55ad8a77d4303b9f73aa966321f70282c8c1fa39 100644 (file)
@@ -30,9 +30,7 @@ class EditExternally(Operator):
     bl_options = {'REGISTER'}
 
     filepath = StringProperty(
-            name="File Path",
-            description="Path to an image file",
-            maxlen=1024,
+            subtype='FILE_PATH',
             )
 
     def _editor_guess(self, context):
index 89029e3af015b1fbfad245a730c23aaf2eb37f64..1da5e2ca381867435b91d427475d8ba66e620040 100644 (file)
@@ -748,8 +748,6 @@ class WM_OT_path_open(Operator):
     bl_label = ""
 
     filepath = StringProperty(
-            name="File Path",
-            maxlen=1024,
             subtype='FILE_PATH',
             )
 
@@ -1085,8 +1083,7 @@ class WM_OT_keyconfig_activate(Operator):
     bl_label = "Activate Keyconfig"
 
     filepath = StringProperty(
-            name="File Path",
-            maxlen=1024,
+            subtype='FILE_PATH',
             )
 
     def execute(self, context):
@@ -1116,8 +1113,7 @@ class WM_OT_appconfig_activate(Operator):
     bl_label = "Activate Application Configuration"
 
     filepath = StringProperty(
-            name="File Path",
-            maxlen=1024,
+            subtype='FILE_PATH',
             )
 
     def execute(self, context):
@@ -1203,8 +1199,7 @@ class WM_OT_keyconfig_import(Operator):
     bl_label = "Import Key Configuration..."
 
     filepath = StringProperty(
-            name="File Path",
-            description="Filepath to write file to",
+            subtype='FILE_PATH',
             default="keymap.py",
             )
     filter_folder = BoolProperty(
@@ -1270,8 +1265,7 @@ class WM_OT_keyconfig_export(Operator):
     bl_label = "Export Key Configuration..."
 
     filepath = StringProperty(
-            name="File Path",
-            description="Filepath to write file to",
+            subtype='FILE_PATH',
             default="keymap.py",
             )
     filter_folder = BoolProperty(
@@ -1513,8 +1507,7 @@ class WM_OT_addon_install(Operator):
             )
 
     filepath = StringProperty(
-            name="File Path",
-            description="File path to write file to",
+            subtype='FILE_PATH',
             )
     filter_folder = BoolProperty(
             name="Filter folders",
index 712429716a619a3f626fffd2da9b1a3f411e2e37..2e8f1a5512eaaffb2a7bcbc69ddce8fd20646cc3 100644 (file)
@@ -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);
index 1ef254d355f4bf7e7c344d19bbd604451109d65a..001b191155d571d016e4d43c9ad34cfc529adeff 100644 (file)
@@ -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");
index 3b65e7772008fe6037608701cea93ec9a1f1684b..682b40affc2979a25867d9794358667216a62c64 100644 (file)
@@ -798,7 +798,7 @@ void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op
        for (ks= builtin_keyingsets.first; ks; ks=ks->next, i--) {
                /* only show KeyingSet if context is suitable */
                if (ANIM_keyingset_context_ok_poll(C, ks))
-                       uiItemEnumO_value(layout, ks->name, ICON_NONE, op_name, "type", i);
+                       uiItemIntO(layout, ks->name, ICON_NONE, op_name, "type", i);
        }
        
        uiPupMenuEnd(C, pup);
index aee23626787046131fffb0bd88b37a73bf0f98f5..6ebfddff5c154d66535b07c387cf6929b8c8deb3 100644 (file)
@@ -5492,6 +5492,11 @@ wmOperator *uiContextActiveOperator(const struct bContext *C)
        ARegion *ar_ctx= CTX_wm_region(C);
        uiBlock *block;
 
+       /* background mode */
+       if (ar_ctx == NULL) {
+               return NULL;
+       }
+
        /* scan active regions ui */
        for(block=ar_ctx->uiblocks.first; block; block=block->next) {
                if (block->ui_operator) {
index 2a75c2a26c15885eb04f0663e6069df19370c763..b50df29918dbba1bc9fd52298d215e5195ea08ac 100644 (file)
@@ -458,11 +458,16 @@ static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op))
         *      - otherwise, up to info (which is what users normally see)
         */
        str = BKE_reports_string(reports, (G.f & G_DEBUG)? RPT_DEBUG : RPT_INFO);
-       
-       write_text(txt, str);
-       MEM_freeN(str);
-       
-       return OPERATOR_FINISHED;
+
+       if (str) {
+               write_text(txt, str);
+               MEM_freeN(str);
+
+               return OPERATOR_FINISHED;
+       }
+       else {
+               return OPERATOR_CANCELLED;
+       }
 }
 
 static void UI_OT_reports_to_textblock(wmOperatorType *ot)
index 58c3c0130b8d4bc96f4e5ca9b8695e8a531520ea..b89a80bb0d759d466d978e85ab6b2e933f4b9691 100644 (file)
@@ -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, ...)
index c690d77594605899ce700b6d5d867e578954c135..6a01e1fc303b324427ccd91f1ff7065d16fc52d7 100644 (file)
@@ -2778,10 +2778,11 @@ static int select_axis_exec(bContext *C, wmOperator *op)
        int axis= RNA_enum_get(op->ptr, "axis");
        int mode= RNA_enum_get(op->ptr, "mode"); /* -1==aligned, 0==neg, 1==pos*/
 
-       if(ese==NULL)
+       if (ese==NULL || ese->htype != BM_VERT) {
+               BKE_report(op->reports, RPT_WARNING, "This operator requires an active vertex (last selected)");
                return OPERATOR_CANCELLED;
-
-       if (ese->htype==BM_VERT) {
+       }
+       else {
                BMVert *ev, *act_vert= (BMVert*)ese->data;
                BMIter iter;
                float value= act_vert->co[axis];
index b87cbcb9d3bacce2fc30f7b65298a6649b8f3934..082332fc3b0e46fb5e9e837136acbabd6ade5048 100644 (file)
@@ -612,7 +612,9 @@ void OBJECT_OT_hook_remove(wmOperatorType *ot)
        ot->poll= hook_op_edit_poll;
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       /* this operator removes modifier which isn't stored in local undo stack,
+          so redoing it from redo panel gives totally weird results  */
+       ot->flag= /*OPTYPE_REGISTER|*/OPTYPE_UNDO;
        
        /* properties */
        prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove");
@@ -799,7 +801,9 @@ void OBJECT_OT_hook_assign(wmOperatorType *ot)
        ot->poll= hook_op_edit_poll;
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       /* this operator changes data stored in modifier which doesn't get pushed to undo stack,
+          so redoing it from redo panel gives totally weird results  */
+       ot->flag= /*OPTYPE_REGISTER|*/OPTYPE_UNDO;
        
        /* properties */
        prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to");
index 04ae926ee068e55b34434df1c96030c8f21eb0fb..3109669602dfec73a59d97b75b499068903c0ea3 100644 (file)
@@ -1843,10 +1843,13 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op))              /* toggle */
 /* for switching to/from mode */
 static int paint_poll_test(bContext *C)
 {
+       Object *ob= CTX_data_active_object(C);
        if(CTX_data_edit_object(C))
                return 0;
        if(CTX_data_active_object(C)==NULL)
                return 0;
+       if(!ob->data || ((ID *)ob->data)->lib)
+               return 0;
        return 1;
 }
 
index fe09c5cd8292d3f1a391a09b6f6570790e3e66f8..941c12df4aa51bc9e9f0cd460824476a837f61b5 100644 (file)
@@ -212,6 +212,7 @@ static void clip_panel_operator_redo_operator(const bContext *C, Panel *pa, wmOp
        }
 }
 
+/* TODO de-duplicate redo panel functions - campbell */
 static void clip_panel_operator_redo(const bContext *C, Panel *pa)
 {
        wmOperator *op= WM_operator_last_redo(C);
@@ -224,7 +225,7 @@ static void clip_panel_operator_redo(const bContext *C, Panel *pa)
 
        block= uiLayoutGetBlock(pa->layout);
 
-       if(ED_undo_valid(C, op->type->name)==0)
+       if (!WM_operator_check_ui_enabled(C, op->type->name))
                uiLayoutSetEnabled(pa->layout, 0);
 
        /* note, blockfunc is a default but->func, use Handle func to allow button callbacks too */
index 69c192b077bc604889c3bb4940ec4d415ddbffe0..daa2031bb5f72e6196d79840cb9be35b93f7c5e7 100644 (file)
@@ -715,7 +715,7 @@ int file_draw_check_exists(SpaceFile *sfile)
                        if(RNA_boolean_get(sfile->op->ptr, "check_existing")) {
                                char filepath[FILE_MAX];
                                BLI_join_dirfile(filepath, sizeof(filepath), sfile->params->dir, sfile->params->file);
-                               if(BLI_exists(filepath) && !BLI_is_dir(filepath)) {
+                               if(BLI_is_file(filepath)) {
                                        return TRUE;
                                }
                        }
@@ -1143,8 +1143,8 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused))
                        BLI_dir_create_recursive(sfile->params->dir);
                }
 
-               /* special case, user may have pasted a fulepath into the directory */
-               if(BLI_exists(sfile->params->dir) && BLI_is_dir(sfile->params->dir) == 0) {
+               /* special case, user may have pasted a filepath into the directory */
+               if(BLI_is_file(sfile->params->dir)) {
                        char path[sizeof(sfile->params->dir)];
                        BLI_strncpy(path, sfile->params->dir, sizeof(path));
                        BLI_split_dirfile(path, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file));
index d226815a1de2d7bf11adcfc7d2e0bdbcb977e45b..cb6a53c67eb353ce3a47ab786632570cc5ada3aa 100644 (file)
@@ -96,6 +96,7 @@ static void view3d_panel_operator_redo_operator(const bContext *C, Panel *pa, wm
        }
 }
 
+/* TODO de-duplicate redo panel functions - campbell */
 static void view3d_panel_operator_redo(const bContext *C, Panel *pa)
 {
        wmOperator *op= WM_operator_last_redo(C);
@@ -108,7 +109,7 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa)
        
        block= uiLayoutGetBlock(pa->layout);
        
-       if(ED_undo_valid(C, op->type->name)==0)
+       if (!WM_operator_check_ui_enabled(C, op->type->name))
                uiLayoutSetEnabled(pa->layout, 0);
 
        /* note, blockfunc is a default but->func, use Handle func to allow button callbacks too */
index 996fab59762b6acffd6fc4bed07258f71f1c8452..be596a9a4a92f1c075263a511e3afff7866e85fd 100644 (file)
@@ -141,8 +141,8 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
        ScrArea *sa= CTX_wm_area(C);
 
        /* undo during jobs are running can easily lead to freeing data using by jobs,
-           or they can just lead to freezing job in some other cases */
-       if(WM_jobs_has_running(CTX_wm_manager(C))) {
+        * or they can just lead to freezing job in some other cases */
+       if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) {
                return OPERATOR_CANCELLED;
        }
 
@@ -356,13 +356,24 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
        int ret= 0;
 
        if(op) {
+               wmWindowManager *wm= CTX_wm_manager(C);
+               struct Scene *scene= CTX_data_scene(C);
+
                ARegion *ar= CTX_wm_region(C);
                ARegion *ar1= BKE_area_find_region_type(CTX_wm_area(C), RGN_TYPE_WINDOW);
 
                if(ar1)
                        CTX_wm_region_set(C, ar1);
 
-               if(WM_operator_repeat_check(C, op) && WM_operator_poll(C, op->type)) {
+               if ( (WM_operator_repeat_check(C, op)) &&
+                    (WM_operator_poll(C, op->type)) &&
+                    /* note, undo/redo cant run if there are jobs active,
+                     * check for screen jobs only so jobs like material/texture/world preview
+                     * (which copy their data), wont stop redo, see [#29579]],
+                     *
+                     * note, - WM_operator_check_ui_enabled() jobs test _must_ stay in sync with this */
+                    (WM_jobs_test(wm, scene) == 0))
+               {
                        int retval;
 
                        if (G.f & G_DEBUG)
index a31984dfc29f0d1fcb9e5ac8d91ef8153e72ffd8..02b1fa300fb2fe44ad4cac820bb8556263e8b3a3 100644 (file)
@@ -469,7 +469,7 @@ static const char *rna_ensure_property_description(PropertyRNA *prop)
        }
 
 #ifdef WITH_INTERNATIONAL
-       if((U.transopts&USER_DOTRANSLATE) && (U.transopts&USER_TR_TOOLTIPS))
+       if(description && (U.transopts&USER_DOTRANSLATE) && (U.transopts&USER_TR_TOOLTIPS))
                description= BLF_gettext(description);
 #endif
 
index 392aa6a7f5a396d9c14720b5b58189f5c277e3cc..612c34d1c92e5c5787ad67781182f48571d575af 100644 (file)
@@ -1404,7 +1404,7 @@ static void rna_def_scene_actuator(BlenderRNA *brna)
        prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "type");
        RNA_def_property_enum_items(prop, prop_type_items);
-       RNA_def_property_ui_text(prop, "Scene", "");
+       RNA_def_property_ui_text(prop, "Mode", "");
        RNA_def_property_update(prop, NC_LOGIC, NULL);
        
        //XXX filter only camera objects
index 2c0e22337c0fecc886a52852ab78060052a1edf2..61c3da362038e8fc46734750ffd0010dea19b2a4 100644 (file)
@@ -191,6 +191,7 @@ struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *
 int                    WM_operator_poll                (struct bContext *C, struct wmOperatorType *ot);
 int                    WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, int context);
 int                    WM_operator_call                (struct bContext *C, struct wmOperator *op);
+int                    WM_operator_call_notest(struct bContext *C, struct wmOperator *op);
 int                    WM_operator_repeat              (struct bContext *C, struct wmOperator *op);
 int                    WM_operator_repeat_check(const struct bContext *C, struct wmOperator *op);
 int                    WM_operator_name_call   (struct bContext *C, const char *opstring, int context, struct PointerRNA *properties);
@@ -206,6 +207,7 @@ void                WM_operator_properties_gesture_border(struct wmOperatorType *ot, int exten
 void           WM_operator_properties_gesture_straightline(struct wmOperatorType *ot, int cursor);
 void           WM_operator_properties_select_all(struct wmOperatorType *ot);
 
+int         WM_operator_check_ui_enabled(const struct bContext *C, const char *idname);
 wmOperator *WM_operator_last_redo(const struct bContext *C);
 
 /* MOVE THIS SOMEWHERE ELSE */
index 9d8f68115cf5b8a25a38c5714eeb417e9c9cf498..1593f14a76c26c3e34cabeba307292862b9ba4a4 100644 (file)
@@ -597,12 +597,36 @@ static int wm_operator_exec(bContext *C, wmOperator *op, int repeat)
        
 }
 
-/* for running operators with frozen context (modal handlers, menus) */
+/* simply calls exec with basic checks */
+static int wm_operator_exec_notest(bContext *C, wmOperator *op)
+{
+       int retval= OPERATOR_CANCELLED;
+
+       if(op==NULL || op->type==NULL || op->type->exec==NULL)
+               return retval;
+
+       retval= op->type->exec(C, op);
+       OPERATOR_RETVAL_CHECK(retval);
+
+       return retval;
+}
+
+/* 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);
 }
 
+/* this is intended to be used when an invoke operator wants to call exec on its self
+ * and is basically like running op->type->exec() directly, no poll checks no freeing,
+ * since we assume whoever called invokle will take care of that */
+int WM_operator_call_notest(bContext *C, wmOperator *op)
+{
+       return wm_operator_exec_notest(C, op);
+}
+
 /* do this operator again, put here so it can share above code */
 int WM_operator_repeat(bContext *C, wmOperator *op)
 {
index fa6521b3ec0f0745b3d86002571b8e8e12cee66f..004b71307df23f4b7d39875459863a7c80616c4c 100644 (file)
@@ -802,7 +802,7 @@ int WM_operator_confirm(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
 int WM_operator_filesel(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
 {
        if (RNA_property_is_set(op->ptr, "filepath")) {
-               return WM_operator_call(C, op);
+               return WM_operator_call_notest(C, op); /* call exec direct */
        } 
        else {
                WM_event_add_fileselect(C, op);
@@ -907,6 +907,15 @@ int WM_operator_winactive(bContext *C)
        return 1;
 }
 
+/* return FALSE, if the UI should be disabled */
+int WM_operator_check_ui_enabled(const bContext *C, const char *idname)
+{
+       wmWindowManager *wm= CTX_wm_manager(C);
+       Scene *scene= CTX_data_scene(C);
+
+       return !(ED_undo_valid(C, idname)==0 || WM_jobs_test(wm, scene));
+}
+
 wmOperator *WM_operator_last_redo(const bContext *C)
 {
        wmWindowManager *wm= CTX_wm_manager(C);
@@ -940,7 +949,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
        uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, arg_op);
        layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, width, UI_UNIT_Y, style);
 
-       if(ED_undo_valid(C, op->type->name)==0)
+       if (!WM_operator_check_ui_enabled(C, op->type->name))
                uiLayoutSetEnabled(layout, 0);
 
        if(op->type->flag & OPTYPE_MACRO) {
@@ -1628,7 +1637,7 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
 static int wm_link_append_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
 {
        if(RNA_property_is_set(op->ptr, "filepath")) {
-               return WM_operator_call(C, op);
+               return WM_operator_call_notest(C, op);
        } 
        else {
                /* XXX TODO solve where to get last linked library from */
@@ -1994,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)
@@ -2018,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)