GP allows to access pie menus out of context #48200

Closed
opened 2016-04-19 22:21:15 +02:00 by Aaron Carlisle · 11 comments
Member

System Information
Windows 10
Intel HD 4600

Blender Version
Broken: 2.77a
Worked: N/A

Short description of error
GP allows to access pie menus put of context. To reproduce this you must have pie menus add-on enabled.

Exact steps for others to reproduce the error

  1. Go to node editor with node enabled
  2. CTRL+D to draw GP
  3. enable GP editing (tool shelf)
  4. hit tab

Video: https://drive.google.com/file/d/0B4CLCL8cP5lSeWxFWEx6NVZJWWs/view?usp=sharing

**System Information** Windows 10 Intel HD 4600 **Blender Version** Broken: 2.77a Worked: N/A **Short description of error** GP allows to access pie menus put of context. To reproduce this you must have pie menus add-on enabled. **Exact steps for others to reproduce the error** 1. Go to node editor with node enabled 2. CTRL+D to draw GP 3. enable GP editing (tool shelf) 4. hit tab Video: https://drive.google.com/file/d/0B4CLCL8cP5lSeWxFWEx6NVZJWWs/view?usp=sharing
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @Blendify

Added subscriber: @Blendify
Author
Member

Added subscriber: @JulianEisel

Added subscriber: @JulianEisel
Aaron Carlisle changed title from GP allows to access pie menus put of context to GP allows to access pie menus out of context 2016-04-19 23:05:15 +02:00
Julian Eisel self-assigned this 2016-04-20 01:11:50 +02:00
Member

Think this needs a two-step fix:

  1. Poll pie to only allow creation in 3D views
diff --git a/ui_pie_menus_official.py b/ui_pie_menus_official.py
index d78aeaf..6ead176 100644
--- a/ui_pie_menus_official.py
+++ b/ui_pie_menus_official.py
@@ -37,6 +37,10 @@ from bpy.props import EnumProperty
 class VIEW3D_PIE_object_mode(Menu):
     bl_label = "Mode"
 
+    @classmethod
+    def poll(cls, context):
+        return (context.space_data.type == 'VIEW_3D')
+
     def draw(self, context):
         layout = self.layout
 
  1. Allow event to pass through so that toggling out of GPencil edit mode using tab works:
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index b3972be..17fa7ed 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -3006,7 +3006,7 @@ int UI_pie_menu_invoke(struct bContext *C, const char *idname, const wmEvent *ev
        }
 
        if (mt->poll && mt->poll(C, mt) == 0)
-               return OPERATOR_CANCELLED;
+               return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
 
        pie = UI_pie_menu_begin(C, IFACE_(mt->label), ICON_NONE, event);
        layout = UI_pie_menu_layout(pie);
@@ -3237,7 +3237,7 @@ int UI_popup_menu_invoke(bContext *C, const char *idname, ReportList *reports)
        }
 
        if (mt->poll && mt->poll(C, mt) == 0)
-               return OPERATOR_CANCELLED;
+               return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
 
        pup = UI_popup_menu_begin(C, IFACE_(mt->label), ICON_NONE);
        layout = UI_popup_menu_layout(pup);

Hard to predict how safe second change is, guess we just have to try it.

Note that it was also possible to recreate in other editors with GPencil support.

Think this needs a two-step fix: 1. Poll pie to only allow creation in 3D views ``` diff --git a/ui_pie_menus_official.py b/ui_pie_menus_official.py index d78aeaf..6ead176 100644 --- a/ui_pie_menus_official.py +++ b/ui_pie_menus_official.py @@ -37,6 +37,10 @@ from bpy.props import EnumProperty class VIEW3D_PIE_object_mode(Menu): bl_label = "Mode" + @classmethod + def poll(cls, context): + return (context.space_data.type == 'VIEW_3D') + def draw(self, context): layout = self.layout ``` 2. Allow event to pass through so that toggling out of GPencil edit mode using tab works: ``` diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index b3972be..17fa7ed 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -3006,7 +3006,7 @@ int UI_pie_menu_invoke(struct bContext *C, const char *idname, const wmEvent *ev } if (mt->poll && mt->poll(C, mt) == 0) - return OPERATOR_CANCELLED; + return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); pie = UI_pie_menu_begin(C, IFACE_(mt->label), ICON_NONE, event); layout = UI_pie_menu_layout(pie); @@ -3237,7 +3237,7 @@ int UI_popup_menu_invoke(bContext *C, const char *idname, ReportList *reports) } if (mt->poll && mt->poll(C, mt) == 0) - return OPERATOR_CANCELLED; + return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); pup = UI_popup_menu_begin(C, IFACE_(mt->label), ICON_NONE); layout = UI_popup_menu_layout(pup); ``` Hard to predict how safe second change is, guess we just have to try it. Note that it was also possible to recreate in other editors with GPencil support.
Member

Added subscriber: @BrendonMurphy

Added subscriber: @BrendonMurphy
Member

hi, the main issue here is context sensitivity. Rather than try to find workarounds, the menu needs to be re-written with proper per mode polls & menu's added in most operators.

hi, the main issue here is context sensitivity. Rather than try to find workarounds, the menu needs to be re-written with proper per mode polls & menu's added in most operators.
Member

@BrendonMurphy ? What I proposed is adding a poll function to the menu. Plus an event system correction for something that looks incorrect to me. It's definitely not just a workaround ;)

@BrendonMurphy ? What I proposed *is* adding a poll function to the menu. Plus an event system correction for something that looks incorrect to me. It's definitely not just a workaround ;)
Member

Hi, @JulianEisel sorry if that was a little abrupt. You are right, what you did is not a workaround. however I don't think it takes it far enough, from my too brief look at this, there's edit mode pies in object mode & generally no context sensitivity throughout.

Hi, @JulianEisel sorry if that was a little abrupt. You are right, what you did is not a workaround. however I don't think it takes it far enough, from my too brief look at this, there's edit mode pies in object mode & generally no context sensitivity throughout.
Member

@JulianEisel hi, I'm tempted to rewrite this addon, your poll is a good start, just need context sensitivity elsewhere to refine the addon, this should be easily solvable with operator context polls. I'll make a patch for this soon.
I wouldn't be adding exceptions in C just yet, (would it affect other addons?) might need more discuss, it may be useful, unsure.

@JulianEisel hi, I'm tempted to rewrite this addon, your poll is a good start, just need context sensitivity elsewhere to refine the addon, this should be easily solvable with operator context polls. I'll make a patch for this soon. I wouldn't be adding exceptions in C just yet, (would it affect other addons?) might need more discuss, it may be useful, unsure.

This issue was referenced by 7c3a79b484

This issue was referenced by 7c3a79b484179e34f0d5504ea6a9bdd331e686a1
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#48200
No description provided.