no longer use 'check_existing' to see if we need to have a save popup, instead use 'exec' operator on a saved file and
invoke on unsaved files. correct missing memset --> CustomData_reset switch too.
This commit is contained in:
@@ -1290,7 +1290,7 @@ class WM_OT_blenderplayer_start(Operator):
|
|||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|
||||||
filepath = os.path.join(bpy.app.tempdir, "game.blend")
|
filepath = os.path.join(bpy.app.tempdir, "game.blend")
|
||||||
bpy.ops.wm.save_as_mainfile(filepath=filepath, check_existing=False, copy=True)
|
bpy.ops.wm.save_as_mainfile('EXEC_DEFAULT', filepath=filepath, copy=True)
|
||||||
subprocess.call([player_path, filepath])
|
subprocess.call([player_path, filepath])
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
@@ -112,8 +112,9 @@ class INFO_MT_file(Menu):
|
|||||||
|
|
||||||
layout.separator()
|
layout.separator()
|
||||||
|
|
||||||
layout.operator_context = 'INVOKE_AREA'
|
layout.operator_context = 'EXEC_AREA' if context.blend_data.is_saved else 'INVOKE_AREA'
|
||||||
layout.operator("wm.save_mainfile", text="Save", icon='FILE_TICK').check_existing = False
|
layout.operator("wm.save_mainfile", text="Save", icon='FILE_TICK')
|
||||||
|
|
||||||
layout.operator_context = 'INVOKE_AREA'
|
layout.operator_context = 'INVOKE_AREA'
|
||||||
layout.operator("wm.save_as_mainfile", text="Save As...", icon='SAVE_AS')
|
layout.operator("wm.save_as_mainfile", text="Save As...", icon='SAVE_AS')
|
||||||
layout.operator_context = 'INVOKE_AREA'
|
layout.operator_context = 'INVOKE_AREA'
|
||||||
|
@@ -944,7 +944,7 @@ void BKE_mesh_calc_edges(Mesh *mesh, int update)
|
|||||||
totedge = BLI_edgehash_size(eh);
|
totedge = BLI_edgehash_size(eh);
|
||||||
|
|
||||||
/* write new edges into a temporary CustomData */
|
/* write new edges into a temporary CustomData */
|
||||||
memset(&edata, 0, sizeof(edata));
|
CustomData_reset(&edata);
|
||||||
CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
|
CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
|
||||||
|
|
||||||
med = CustomData_get_layer(&edata, CD_MEDGE);
|
med = CustomData_get_layer(&edata, CD_MEDGE);
|
||||||
|
@@ -1576,22 +1576,6 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
|
|||||||
/* needed for uiPupMenuReports */
|
/* needed for uiPupMenuReports */
|
||||||
|
|
||||||
if (event->val == EVT_FILESELECT_EXEC) {
|
if (event->val == EVT_FILESELECT_EXEC) {
|
||||||
#if 0 // use REDALERT now
|
|
||||||
|
|
||||||
/* a bit weak, might become arg for WM_event_fileselect? */
|
|
||||||
/* XXX also extension code in image-save doesnt work for this yet */
|
|
||||||
if (RNA_struct_find_property(handler->op->ptr, "check_existing") &&
|
|
||||||
RNA_boolean_get(handler->op->ptr, "check_existing"))
|
|
||||||
{
|
|
||||||
char *path = RNA_string_get_alloc(handler->op->ptr, "filepath", NULL, 0);
|
|
||||||
/* this gives ownership to pupmenu */
|
|
||||||
uiPupMenuSaveOver(C, handler->op, (path) ? path : "");
|
|
||||||
if (path)
|
|
||||||
MEM_freeN(path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (handler->op->type->flag & OPTYPE_UNDO)
|
if (handler->op->type->flag & OPTYPE_UNDO)
|
||||||
@@ -1642,7 +1626,6 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
|
|||||||
|
|
||||||
WM_operator_free(handler->op);
|
WM_operator_free(handler->op);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
if (handler->op->type->cancel) {
|
if (handler->op->type->cancel) {
|
||||||
if (handler->op->type->flag & OPTYPE_UNDO)
|
if (handler->op->type->flag & OPTYPE_UNDO)
|
||||||
|
@@ -859,6 +859,8 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type,
|
|||||||
RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", "");
|
RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", "");
|
||||||
|
|
||||||
if (action == FILE_SAVE) {
|
if (action == FILE_SAVE) {
|
||||||
|
/* note, this is only used to check if we should highlight the filename area red when the
|
||||||
|
* filepath is an existing file. */
|
||||||
prop = RNA_def_boolean(ot->srna, "check_existing", 1, "Check Existing", "Check and warn on overwriting existing files");
|
prop = RNA_def_boolean(ot->srna, "check_existing", 1, "Check Existing", "Check and warn on overwriting existing files");
|
||||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||||
}
|
}
|
||||||
@@ -2117,7 +2119,6 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot)
|
|||||||
static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||||
{
|
{
|
||||||
char name[FILE_MAX];
|
char name[FILE_MAX];
|
||||||
int check_existing = 1;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* cancel if no active window */
|
/* cancel if no active window */
|
||||||
@@ -2138,12 +2139,8 @@ static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(
|
|||||||
|
|
||||||
RNA_string_set(op->ptr, "filepath", name);
|
RNA_string_set(op->ptr, "filepath", name);
|
||||||
|
|
||||||
if (RNA_struct_find_property(op->ptr, "check_existing"))
|
|
||||||
if (RNA_boolean_get(op->ptr, "check_existing") == 0)
|
|
||||||
check_existing = 0;
|
|
||||||
|
|
||||||
if (G.save_over) {
|
if (G.save_over) {
|
||||||
if (check_existing && BLI_exists(name)) {
|
if (BLI_exists(name)) {
|
||||||
uiPupMenuSaveOver(C, op, name);
|
uiPupMenuSaveOver(C, op, name);
|
||||||
ret = OPERATOR_RUNNING_MODAL;
|
ret = OPERATOR_RUNNING_MODAL;
|
||||||
}
|
}
|
||||||
|
@@ -145,7 +145,7 @@ def main():
|
|||||||
|
|
||||||
if write_blend is not None:
|
if write_blend is not None:
|
||||||
print(" Writing Blend: %s" % write_blend)
|
print(" Writing Blend: %s" % write_blend)
|
||||||
bpy.ops.wm.save_mainfile(filepath=write_blend, check_existing=False)
|
bpy.ops.wm.save_mainfile('EXEC_DEFAULT', filepath=write_blend)
|
||||||
|
|
||||||
print(" Result: '%s'" % str(result))
|
print(" Result: '%s'" % str(result))
|
||||||
if not result:
|
if not result:
|
||||||
|
Reference in New Issue
Block a user