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:
authorGermano <germano.costa@ig.com.br>2018-01-31 16:07:25 +0300
committerGermano <germano.costa@ig.com.br>2018-01-31 16:07:25 +0300
commit483b981d635f02da4a4529c586a337705a03cf62 (patch)
tree5565fa7b91b45d58fabbcba4936b521e2630f58b /source/blender/editors/space_outliner/outliner_tools.c
parent6d55b522feb61a6cc03d04cbc2fca23713964084 (diff)
Outliner: Fix crash when invoking operators of a collection or group
The crash occurred when trying to see a tooltip or activate any of the operator's tools with the cursor outside the outliner area.
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_tools.c')
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c52
1 files changed, 25 insertions, 27 deletions
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 9f0165d1272..40ade8a821d 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -1841,7 +1841,7 @@ void OUTLINER_OT_modifier_operation(wmOperatorType *ot)
/* ******************** */
-static EnumPropertyItem prop_collection_op_none_types[] = {
+static EnumPropertyItem prop_collection_op_types[] = {
{OL_COLLECTION_OP_OBJECTS_ADD, "OBJECTS_ADD", ICON_ZOOMIN, "Add Selected", "Add selected objects to collection"},
{OL_COLLECTION_OP_OBJECTS_REMOVE, "OBJECTS_REMOVE", ICON_X, "Remove Selected", "Remove selected objects from collection"},
{OL_COLLECTION_OP_COLLECTION_NEW, "COLLECTION_NEW", ICON_NEW, "New Collection", "Add a new nested collection"},
@@ -1851,29 +1851,6 @@ static EnumPropertyItem prop_collection_op_none_types[] = {
{0, NULL, 0, NULL, NULL}
};
-static EnumPropertyItem prop_collection_op_group_internal_types[] = {
- {OL_COLLECTION_OP_OBJECTS_ADD, "OBJECTS_ADD", ICON_ZOOMIN, "Add Selected", "Add selected objects to collection"},
- {OL_COLLECTION_OP_OBJECTS_REMOVE, "OBJECTS_REMOVE", ICON_X, "Remove Selected", "Remove selected objects from collection"},
- {OL_COLLECTION_OP_COLLECTION_NEW, "COLLECTION_NEW", ICON_NEW, "New Collection", "Add a new nested collection"},
- {OL_COLLECTION_OP_COLLECTION_DEL, "COLLECTION_DEL", ICON_X, "Delete Collection", "Delete the collection"},
- {0, NULL, 0, NULL, NULL}
-};
-
-static const EnumPropertyItem *outliner_collection_operation_type_itemf(
- bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
-{
- *r_free = false;
- SpaceOops *soops = CTX_wm_space_outliner(C);
-
- switch (soops->outlinevis) {
- case SO_GROUPS:
- return prop_collection_op_group_internal_types;
- case SO_VIEW_LAYER:
- return prop_collection_op_none_types;
- }
- return NULL;
-}
-
static int outliner_collection_operation_exec(bContext *C, wmOperator *op)
{
SpaceOops *soops = CTX_wm_space_outliner(C);
@@ -1892,6 +1869,28 @@ static int outliner_collection_operation_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static int outliner_collection_operation_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ SpaceOops *soops = CTX_wm_space_outliner(C);
+ wmOperatorType *ot = op->type;
+ EnumPropertyItem *prop = &prop_collection_op_types[0];
+
+ uiPopupMenu *pup = UI_popup_menu_begin(C, "Collection", ICON_NONE);
+ uiLayout *layout = UI_popup_menu_layout(pup);
+
+ for (int i = 0; i < (ARRAY_SIZE(prop_collection_op_types) - 1); i++, prop++) {
+ if (soops->outlinevis != SO_GROUPS ||
+ !ELEM(prop->value, OL_COLLECTION_OP_COLLECTION_UNLINK, OL_COLLECTION_OP_GROUP_CREATE))
+ {
+ uiItemEnumO_ptr(layout, ot, NULL, prop->icon, "type", prop->value);
+ }
+ }
+
+ UI_popup_menu_end(C, pup);
+
+ return OPERATOR_INTERFACE;
+}
+
void OUTLINER_OT_collection_operation(wmOperatorType *ot)
{
PropertyRNA *prop;
@@ -1902,14 +1901,13 @@ void OUTLINER_OT_collection_operation(wmOperatorType *ot)
ot->description = "";
/* callbacks */
- ot->invoke = WM_menu_invoke;
+ ot->invoke = outliner_collection_operation_invoke;
ot->exec = outliner_collection_operation_exec;
ot->poll = ED_operator_outliner_active;
ot->flag = 0;
- prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Collection Operation", "");
- RNA_def_enum_funcs(prop, outliner_collection_operation_type_itemf);
+ prop = RNA_def_enum(ot->srna, "type", prop_collection_op_types, OL_COLLECTION_OP_OBJECTS_ADD, "Collection Operation", "");
RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}