UI: report if WM_OT_call_menu uses an unknown menu
authorCampbell Barton <ideasman42@gmail.com>
Mon, 10 Feb 2014 03:17:33 +0000 (14:17 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 10 Feb 2014 03:17:33 +0000 (14:17 +1100)
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface_regions.c
source/blender/windowmanager/intern/wm_operators.c

index 55c15ab60adc5cf10d2d14594979027950bace86..71d55c73faadea4f8b24d271ed506fa259b7e4f7 100644 (file)
@@ -349,7 +349,7 @@ void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head);
 struct uiLayout *uiPupMenuLayout(uiPopupMenu *head);
 
 void uiPupMenuReports(struct bContext *C, struct ReportList *reports) ATTR_NONNULL();
-void uiPupMenuInvoke(struct bContext *C, const char *idname) ATTR_NONNULL();
+bool uiPupMenuInvoke(struct bContext *C, const char *idname, struct ReportList *reports) ATTR_NONNULL(1, 2);
 
 /* Popup Blocks
  *
index 2adf18ce3343d1bf121ce227fc00364bece72ee1..9bb8ed0d1e07602147c8715e033704638ef7b300 100644 (file)
@@ -47,6 +47,7 @@
 #include "BKE_context.h"
 #include "BKE_screen.h"
 #include "BKE_idcode.h"
+#include "BKE_report.h"
 #include "BKE_global.h"
 
 #include "WM_api.h"
@@ -2369,7 +2370,7 @@ void uiPupMenuReports(bContext *C, ReportList *reports)
        }
 }
 
-void uiPupMenuInvoke(bContext *C, const char *idname)
+bool uiPupMenuInvoke(bContext *C, const char *idname, ReportList *reports)
 {
        uiPopupMenu *pup;
        uiLayout *layout;
@@ -2377,12 +2378,12 @@ void uiPupMenuInvoke(bContext *C, const char *idname)
        MenuType *mt = WM_menutype_find(idname, true);
 
        if (mt == NULL) {
-               printf("%s: named menu \"%s\" not found\n", __func__, idname);
-               return;
+               BKE_reportf(reports, RPT_ERROR, "menu \"%s\" not found\n", idname);
+               return false;
        }
 
        if (mt->poll && mt->poll(C, mt) == 0)
-               return;
+               return false;
 
        pup = uiPupMenuBegin(C, IFACE_(mt->label), ICON_NONE);
        layout = uiPupMenuLayout(pup);
@@ -2397,6 +2398,8 @@ void uiPupMenuInvoke(bContext *C, const char *idname)
        mt->draw(C, &menu);
 
        uiPupMenuEnd(C, pup);
+
+       return true;
 }
 
 
index 45cfd2ca61cbb113b74b1a3555358426ca791c45..add726e53e8a644fe54d4cfb9e5ff4c74a564e3b 100644 (file)
@@ -1985,7 +1985,7 @@ static int wm_call_menu_exec(bContext *C, wmOperator *op)
        char idname[BKE_ST_MAXNAME];
        RNA_string_get(op->ptr, "name", idname);
 
-       uiPupMenuInvoke(C, idname);
+       uiPupMenuInvoke(C, idname, op->reports);
 
        return OPERATOR_CANCELLED;
 }