[Bf-blender-cvs] [cb9bd23] master: Fix T44930: File-select in redo panel, disables UI

Campbell Barton noreply at git.blender.org
Tue Jun 9 09:19:18 CEST 2015


Commit: cb9bd23d0cac33c456c97c207cac4539269db518
Author: Campbell Barton
Date:   Tue Jun 9 17:17:22 2015 +1000
Branches: master
https://developer.blender.org/rBcb9bd23d0cac33c456c97c207cac4539269db518

Fix T44930: File-select in redo panel, disables UI

===================================================================

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/space_buttons/buttons_ops.c

===================================================================

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index ef0a57f..1976d99 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -991,7 +991,7 @@ void UI_context_active_but_prop_get(const struct bContext *C, struct PointerRNA
 void UI_context_active_but_prop_handle(struct bContext *C);
 struct wmOperator *UI_context_active_operator_get(const struct bContext *C);
 void UI_context_update_anim_flag(const struct bContext *C);
-void UI_context_active_but_prop_get_filebrowser(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
+void UI_context_active_but_prop_get_filebrowser(const struct bContext *C, struct PointerRNA *r_ptr, struct PropertyRNA **r_prop, bool *r_is_undo);
 void UI_context_active_but_prop_get_templateID(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
 
 /* Styled text draw */
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 279d728..a61b208 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -683,14 +683,17 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n
 	return but;
 }
 
-void UI_context_active_but_prop_get_filebrowser(const bContext *C, PointerRNA *ptr, PropertyRNA **prop)
+void UI_context_active_but_prop_get_filebrowser(
+        const bContext *C,
+        PointerRNA *r_ptr, PropertyRNA **r_prop, bool *r_is_undo)
 {
 	ARegion *ar = CTX_wm_region(C);
 	uiBlock *block;
 	uiBut *but, *prevbut;
 
-	memset(ptr, 0, sizeof(*ptr));
-	*prop = NULL;
+	memset(r_ptr, 0, sizeof(*r_ptr));
+	*r_prop = NULL;
+	*r_is_undo = false;
 
 	if (!ar)
 		return;
@@ -702,8 +705,9 @@ void UI_context_active_but_prop_get_filebrowser(const bContext *C, PointerRNA *p
 			/* find the button before the active one */
 			if ((but->flag & UI_BUT_LAST_ACTIVE) && prevbut && prevbut->rnapoin.data) {
 				if (RNA_property_type(prevbut->rnaprop) == PROP_STRING) {
-					*ptr = prevbut->rnapoin;
-					*prop = prevbut->rnaprop;
+					*r_ptr = prevbut->rnapoin;
+					*r_prop = prevbut->rnaprop;
+					*r_is_undo = (prevbut->flag & UI_BUT_UNDO) != 0;
 					return;
 				}
 			}
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index ba0c22a..8ad4858 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -97,6 +97,7 @@ void BUTTONS_OT_toolbox(wmOperatorType *ot)
 typedef struct FileBrowseOp {
 	PointerRNA ptr;
 	PropertyRNA *prop;
+	bool is_undo;
 } FileBrowseOp;
 
 static int file_browse_exec(bContext *C, wmOperator *op)
@@ -142,6 +143,10 @@ static int file_browse_exec(bContext *C, wmOperator *op)
 	RNA_property_update(C, &fbo->ptr, fbo->prop);
 	MEM_freeN(str);
 
+	if (fbo->is_undo) {
+		const char *undostr = RNA_property_identifier(fbo->prop);
+		ED_undo_push(C, undostr);
+	}
 
 	/* special, annoying exception, filesel on redo panel [#26618] */
 	{
@@ -168,6 +173,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
 	PointerRNA ptr;
 	PropertyRNA *prop;
+	bool is_undo;
 	FileBrowseOp *fbo;
 	char *str;
 
@@ -176,7 +182,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 		return OPERATOR_CANCELLED;
 	}
 
-	UI_context_active_but_prop_get_filebrowser(C, &ptr, &prop);
+	UI_context_active_but_prop_get_filebrowser(C, &ptr, &prop, &is_undo);
 
 	if (!prop)
 		return OPERATOR_CANCELLED;
@@ -210,6 +216,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 		fbo = MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp");
 		fbo->ptr = ptr;
 		fbo->prop = prop;
+		fbo->is_undo = is_undo;
 		op->customdata = fbo;
 
 		RNA_string_set(op->ptr, path_prop, str);
@@ -241,7 +248,8 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot)
 	ot->exec = file_browse_exec;
 	ot->cancel = file_browse_cancel;
 
-	ot->flag |= OPTYPE_UNDO;
+	/* conditional undo based on button flag */
+	ot->flag = 0;
 
 	/* properties */
 	WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE,
@@ -261,7 +269,8 @@ void BUTTONS_OT_directory_browse(wmOperatorType *ot)
 	ot->exec = file_browse_exec;
 	ot->cancel = file_browse_cancel;
 
-	ot->flag |= OPTYPE_UNDO;
+	/* conditional undo based on button flag */
+	ot->flag = 0;
 
 	/* properties */
 	WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE,




More information about the Bf-blender-cvs mailing list