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:
Diffstat (limited to 'source/blender/editors/space_buttons')
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c31
-rw-r--r--source/blender/editors/space_buttons/buttons_intern.h1
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c15
3 files changed, 43 insertions, 4 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 73091e7f261..bc42f1dd5bb 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -59,6 +59,7 @@
#include "RNA_access.h"
+#include "ED_buttons.h"
#include "ED_armature.h"
#include "ED_screen.h"
#include "ED_physics.h"
@@ -1179,3 +1180,33 @@ ID *buttons_context_id_path(const bContext *C)
return NULL;
}
+
+void ED_buttons_id_unref(SpaceButs *sbuts, const ID *id)
+{
+ if (sbuts->pinid == id) {
+ sbuts->pinid = NULL;
+ sbuts->flag &= ~SB_PIN_CONTEXT;
+ }
+
+ if (sbuts->path) {
+ ButsContextPath *path = sbuts->path;
+ int i;
+
+ for (i = 0; i < path->len; i++) {
+ if (path->ptr[i].id.data == id) {
+ break;
+ }
+ }
+
+ if (i == path->len) {
+ /* pass */
+ }
+ else if (i == 0) {
+ MEM_SAFE_FREE(sbuts->path);
+ }
+ else {
+ memset(&path->ptr[i], 0, sizeof(path->ptr[i]) * (path->len - i));
+ path->len = i;
+ }
+ }
+}
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index f294729ae97..7fc35a6b1e7 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -34,7 +34,6 @@
#include "DNA_listBase.h"
#include "RNA_types.h"
-struct ARegion;
struct ARegionType;
struct ID;
struct SpaceButs;
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index ba0c22a4ade..8ad4858ff22 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,