Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / interface / interface_region_menu_popup.c
index a6046e551c648a88ac7296816c6322524c349c9d..b9222a75803a08a94e1ab94845e0151522e67e9a 100644 (file)
@@ -458,6 +458,21 @@ void UI_popup_menu_end(bContext *C, uiPopupMenu *pup)
        MEM_freeN(pup);
 }
 
        MEM_freeN(pup);
 }
 
+bool UI_popup_menu_end_or_cancel(bContext *C, uiPopupMenu *pup)
+{
+       if (!UI_block_is_empty(pup->block)) {
+               UI_popup_menu_end(C, pup);
+               return true;
+       }
+       else {
+               UI_block_layout_resolve(pup->block, NULL, NULL);
+               MEM_freeN(pup->block->handle);
+               UI_block_free(C, pup->block);
+               MEM_freeN(pup);
+               return false;
+       }
+}
+
 uiLayout *UI_popup_menu_layout(uiPopupMenu *pup)
 {
        return pup->layout;
 uiLayout *UI_popup_menu_layout(uiPopupMenu *pup)
 {
        return pup->layout;