Cleanup: Use StringRef for some WM and UI APIs

Instead of const char * or StringRefNull.

Pull Request: https://projects.blender.org/blender/blender/pulls/134004
This commit is contained in:
Hans Goudey
2025-02-04 13:53:30 +01:00
committed by Hans Goudey
parent eda2f11f7a
commit 73b25ba12e
14 changed files with 87 additions and 82 deletions

View File

@@ -141,7 +141,7 @@ void draw_menu_for_catalog(const asset_system::AssetCatalogTreeItem &item,
{
uiLayout *col = uiLayoutColumn(&layout, false);
uiLayoutSetContextString(col, "asset_catalog_path", item.catalog_path().c_str());
uiItemM(col, menu_name.c_str(), IFACE_(item.get_name().c_str()), ICON_NONE);
uiItemM(col, menu_name, IFACE_(item.get_name().c_str()), ICON_NONE);
}
} // namespace blender::ed::asset

View File

@@ -2885,11 +2885,8 @@ void uiTemplateAssetView(uiLayout *layout,
namespace blender::ui {
void template_asset_shelf_popover(uiLayout &layout,
const bContext &C,
StringRefNull asset_shelf_id,
StringRefNull name,
int icon);
void template_asset_shelf_popover(
uiLayout &layout, const bContext &C, StringRefNull asset_shelf_id, StringRef name, int icon);
}
@@ -3154,13 +3151,13 @@ void uiItemLDrag(uiLayout *layout, PointerRNA *ptr, blender::StringRef name, int
*/
void uiItemM_ptr(uiLayout *layout, MenuType *mt, std::optional<blender::StringRef> name, int icon);
void uiItemM(uiLayout *layout,
blender::StringRefNull menuname,
blender::StringRef menuname,
std::optional<blender::StringRef> name,
int icon);
/**
* Menu contents.
*/
void uiItemMContents(uiLayout *layout, blender::StringRefNull menuname);
void uiItemMContents(uiLayout *layout, blender::StringRef menuname);
/* Decorators. */
@@ -3195,12 +3192,12 @@ void uiItemProgressIndicator(uiLayout *layout,
void uiItemPopoverPanel_ptr(uiLayout *layout,
const bContext *C,
PanelType *pt,
std::optional<blender::StringRefNull> name_opt,
std::optional<blender::StringRef> name_opt,
int icon);
void uiItemPopoverPanel(uiLayout *layout,
const bContext *C,
blender::StringRefNull panel_type,
std::optional<blender::StringRefNull> name_opt,
blender::StringRef panel_type,
std::optional<blender::StringRef> name_opt,
int icon);
void uiItemPopoverPanelFromGroup(uiLayout *layout,
bContext *C,

View File

@@ -3067,23 +3067,23 @@ void uiItemM_ptr(uiLayout *layout, MenuType *mt, const std::optional<StringRef>
}
void uiItemM(uiLayout *layout,
const StringRefNull menuname,
const StringRef menuname,
const std::optional<StringRef> name,
int icon)
{
MenuType *mt = WM_menutype_find(menuname.c_str(), false);
MenuType *mt = WM_menutype_find(menuname, false);
if (mt == nullptr) {
RNA_warning("not found %s", menuname.c_str());
RNA_warning("not found %s", std::string(menuname).c_str());
return;
}
uiItemM_ptr(layout, mt, name, icon);
}
void uiItemMContents(uiLayout *layout, const StringRefNull menuname)
void uiItemMContents(uiLayout *layout, const StringRef menuname)
{
MenuType *mt = WM_menutype_find(menuname.c_str(), false);
MenuType *mt = WM_menutype_find(menuname, false);
if (mt == nullptr) {
RNA_warning("not found %s", menuname.c_str());
RNA_warning("not found %s", std::string(menuname).c_str());
return;
}
@@ -3182,10 +3182,10 @@ void uiItemDecoratorR(uiLayout *layout,
void uiItemPopoverPanel_ptr(uiLayout *layout,
const bContext *C,
PanelType *pt,
const std::optional<StringRefNull> name_opt,
const std::optional<StringRef> name_opt,
int icon)
{
const StringRefNull name = name_opt.value_or(CTX_IFACE_(pt->translation_context, pt->label));
const StringRef name = name_opt.value_or(CTX_IFACE_(pt->translation_context, pt->label));
if (layout->root->type == UI_LAYOUT_MENU && !icon) {
icon = ICON_BLANK1;
@@ -3219,13 +3219,13 @@ void uiItemPopoverPanel_ptr(uiLayout *layout,
void uiItemPopoverPanel(uiLayout *layout,
const bContext *C,
const blender::StringRefNull panel_type,
std::optional<blender::StringRefNull> name_opt,
const StringRef panel_type,
std::optional<blender::StringRef> name_opt,
int icon)
{
PanelType *pt = WM_paneltype_find(panel_type.c_str(), true);
PanelType *pt = WM_paneltype_find(panel_type, true);
if (pt == nullptr) {
RNA_warning("Panel type not found '%s'", panel_type.c_str());
RNA_warning("Panel type not found '%s'", std::string(panel_type).c_str());
return;
}
uiItemPopoverPanel_ptr(layout, C, pt, name_opt, icon);

View File

@@ -26,7 +26,7 @@ namespace blender::ui {
void template_asset_shelf_popover(uiLayout &layout,
const bContext &C,
const StringRefNull asset_shelf_id,
const StringRefNull name,
const StringRef name,
const BIFIconID icon)
{
AssetShelfType *shelf_type = ed::asset::shelf::type_find_from_idname(asset_shelf_id);
@@ -53,7 +53,7 @@ void template_asset_shelf_popover(uiLayout &layout,
ed::asset::shelf::ensure_asset_library_fetched(C, *shelf_type);
uiItemPopoverPanel(row, &C, "ASSETSHELF_PT_popover_panel", name.c_str(), icon);
uiItemPopoverPanel(row, &C, "ASSETSHELF_PT_popover_panel", name, icon);
uiBut *but = static_cast<uiBut *>(block->buttons.last);
if (use_preview_icon) {
ui_def_but_icon(but, icon, UI_HAS_ICON | UI_BUT_ICON_PREVIEW);

View File

@@ -370,7 +370,7 @@ static void uilist_free_dyn_data(uiList *ui_list)
*
* \return false if the input data isn't valid. Will also raise an RNA warning in that case.
*/
static bool ui_template_list_data_retrieve(const char *listtype_name,
static bool ui_template_list_data_retrieve(const StringRef listtype_name,
const char *list_id,
PointerRNA *dataptr,
const StringRefNull propname,
@@ -383,7 +383,7 @@ static bool ui_template_list_data_retrieve(const char *listtype_name,
*r_input_data = {};
/* Forbid default UI_UL_DEFAULT_CLASS_NAME list class without a custom list_id! */
if (STREQ(UI_UL_DEFAULT_CLASS_NAME, listtype_name) && !(list_id && list_id[0])) {
if ((UI_UL_DEFAULT_CLASS_NAME == listtype_name) && !(list_id && list_id[0])) {
RNA_warning("template_list using default '%s' UIList class must provide a custom list_id",
UI_UL_DEFAULT_CLASS_NAME);
return false;
@@ -429,7 +429,7 @@ static bool ui_template_list_data_retrieve(const char *listtype_name,
/* Find the uiList type. */
if (!(*r_list_type = WM_uilisttype_find(listtype_name, false))) {
RNA_warning("List type %s not found", listtype_name);
RNA_warning("List type %s not found", std::string(listtype_name).c_str());
return false;
}

View File

@@ -1269,7 +1269,7 @@ void WM_operator_type_modal_from_exec_for_object_edit_coords(wmOperatorType *ot)
* Called on initialize #WM_init()
*/
void WM_uilisttype_init();
uiListType *WM_uilisttype_find(const char *idname, bool quiet);
uiListType *WM_uilisttype_find(blender::StringRef idname, bool quiet);
bool WM_uilisttype_add(uiListType *ult);
void WM_uilisttype_remove_ptr(Main *bmain, uiListType *ult);
void WM_uilisttype_free();
@@ -1300,7 +1300,7 @@ const char *WM_uilisttype_list_id_get(const uiListType *ult, uiList *list);
* \note Called on initialize #WM_init().
*/
void WM_menutype_init();
MenuType *WM_menutype_find(const char *idname, bool quiet);
MenuType *WM_menutype_find(blender::StringRef idname, bool quiet);
blender::Span<MenuType *> WM_menutypes_registered_get();
bool WM_menutype_add(MenuType *mt);
void WM_menutype_freelink(MenuType *mt);
@@ -1321,7 +1321,7 @@ void WM_menutype_idname_visit_for_search(
*/
void WM_paneltype_init();
void WM_paneltype_clear();
PanelType *WM_paneltype_find(const char *idname, bool quiet);
PanelType *WM_paneltype_find(blender::StringRef idname, bool quiet);
bool WM_paneltype_add(PanelType *pt);
void WM_paneltype_remove(PanelType *pt);

View File

@@ -16,6 +16,8 @@
#include "WM_gizmo_types.hh"
#include "wm_gizmo_fn.hh"
#include "BLI_string_ref.hh"
struct ARegion;
struct bContext;
struct IDProperty;
@@ -52,7 +54,7 @@ wmGizmo *WM_gizmo_new_ptr(const wmGizmoType *gzt, wmGizmoGroup *gzgroup, Pointer
* if you need to check it exists use #WM_gizmo_new_ptr
* because callers of this function don't NULL check the return value.
*/
wmGizmo *WM_gizmo_new(const char *idname, wmGizmoGroup *gzgroup, PointerRNA *properties);
wmGizmo *WM_gizmo_new(blender::StringRef idname, wmGizmoGroup *gzgroup, PointerRNA *properties);
/**
* \warning this doesn't check #wmGizmoMap (highlight, selection etc).
* Typical use is when freeing the windowing data,
@@ -155,12 +157,14 @@ void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4]);
/* Properties. */
void WM_gizmo_properties_create_ptr(PointerRNA *ptr, wmGizmoType *gzt);
void WM_gizmo_properties_create(PointerRNA *ptr, const char *gtstring);
void WM_gizmo_properties_create(PointerRNA *ptr, blender::StringRef gtstring);
/**
* Similar to #WM_gizmo_properties_create
* except its uses ID properties used for key-maps and macros.
*/
void WM_gizmo_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *gtstring);
void WM_gizmo_properties_alloc(PointerRNA **ptr,
IDProperty **properties,
blender::StringRef gtstring);
void WM_gizmo_properties_sanitize(PointerRNA *ptr, bool no_context);
/**
* Set all props to their default.
@@ -180,10 +184,10 @@ void WM_gizmo_properties_free(PointerRNA *ptr);
/* `wm_gizmo_type.cc` */
const wmGizmoType *WM_gizmotype_find(const char *idname, bool quiet);
const wmGizmoType *WM_gizmotype_find(blender::StringRef idname, bool quiet);
void WM_gizmotype_append(void (*gtfunc)(wmGizmoType *));
void WM_gizmotype_append_ptr(void (*gtfunc)(wmGizmoType *, void *), void *userdata);
bool WM_gizmotype_remove(bContext *C, Main *bmain, const char *idname);
bool WM_gizmotype_remove(bContext *C, Main *bmain, blender::StringRef idname);
void WM_gizmotype_remove_ptr(bContext *C, Main *bmain, wmGizmoType *gzt);
/**
* Free but don't remove from #GHash.
@@ -192,7 +196,7 @@ void WM_gizmotype_free_ptr(wmGizmoType *gzt);
/* `wm_gizmo_group_type.cc` */
wmGizmoGroupType *WM_gizmogrouptype_find(const char *idname, bool quiet);
wmGizmoGroupType *WM_gizmogrouptype_find(blender::StringRef idname, bool quiet);
wmGizmoGroupType *WM_gizmogrouptype_append(void (*wtfunc)(wmGizmoGroupType *));
wmGizmoGroupType *WM_gizmogrouptype_append_ptr(void (*wtfunc)(wmGizmoGroupType *, void *),
void *userdata);
@@ -380,14 +384,16 @@ ARegion *WM_gizmomap_tooltip_init(
wmGizmoMapType *WM_gizmomaptype_find(const wmGizmoMapType_Params *gzmap_params);
wmGizmoMapType *WM_gizmomaptype_ensure(const wmGizmoMapType_Params *gzmap_params);
wmGizmoGroupTypeRef *WM_gizmomaptype_group_find(wmGizmoMapType *gzmap_type, const char *idname);
wmGizmoGroupTypeRef *WM_gizmomaptype_group_find(wmGizmoMapType *gzmap_type,
blender::StringRef idname);
wmGizmoGroupTypeRef *WM_gizmomaptype_group_find_ptr(wmGizmoMapType *gzmap_type,
const wmGizmoGroupType *gzgt);
/**
* Use this for registering gizmos on startup.
* For runtime, use #WM_gizmomaptype_group_link_runtime.
*/
wmGizmoGroupTypeRef *WM_gizmomaptype_group_link(wmGizmoMapType *gzmap_type, const char *idname);
wmGizmoGroupTypeRef *WM_gizmomaptype_group_link(wmGizmoMapType *gzmap_type,
blender::StringRef idname);
wmGizmoGroupTypeRef *WM_gizmomaptype_group_link_ptr(wmGizmoMapType *gzmap_type,
wmGizmoGroupType *gzgt);
@@ -415,11 +421,11 @@ void WM_gizmomaptype_group_free(wmGizmoGroupTypeRef *gzgt_ref);
void WM_gizmo_group_type_add_ptr_ex(wmGizmoGroupType *gzgt, wmGizmoMapType *gzmap_type);
void WM_gizmo_group_type_add_ptr(wmGizmoGroupType *gzgt);
void WM_gizmo_group_type_add(const char *idname);
void WM_gizmo_group_type_add(blender::StringRef idname);
bool WM_gizmo_group_type_ensure_ptr_ex(wmGizmoGroupType *gzgt, wmGizmoMapType *gzmap_type);
bool WM_gizmo_group_type_ensure_ptr(wmGizmoGroupType *gzgt);
bool WM_gizmo_group_type_ensure(const char *idname);
bool WM_gizmo_group_type_ensure(blender::StringRef idname);
/**
* Call #WM_gizmo_group_type_free_ptr after to remove & free.
@@ -428,18 +434,18 @@ void WM_gizmo_group_type_remove_ptr_ex(Main *bmain,
wmGizmoGroupType *gzgt,
wmGizmoMapType *gzmap_type);
void WM_gizmo_group_type_remove_ptr(Main *bmain, wmGizmoGroupType *gzgt);
void WM_gizmo_group_type_remove(Main *bmain, const char *idname);
void WM_gizmo_group_type_remove(Main *bmain, blender::StringRef idname);
void WM_gizmo_group_type_unlink_delayed_ptr_ex(wmGizmoGroupType *gzgt, wmGizmoMapType *gzmap_type);
void WM_gizmo_group_type_unlink_delayed_ptr(wmGizmoGroupType *gzgt);
void WM_gizmo_group_type_unlink_delayed(const char *idname);
void WM_gizmo_group_type_unlink_delayed(blender::StringRef idname);
void WM_gizmo_group_unlink_delayed_ptr_from_space(wmGizmoGroupType *gzgt,
wmGizmoMapType *gzmap_type,
ScrArea *area);
void WM_gizmo_group_type_free_ptr(wmGizmoGroupType *gzgt);
bool WM_gizmo_group_type_free(const char *idname);
bool WM_gizmo_group_type_free(blender::StringRef idname);
/**
* Has the result of unlinking and linking (re-initializes gizmo's).
@@ -448,7 +454,7 @@ void WM_gizmo_group_type_reinit_ptr_ex(Main *bmain,
wmGizmoGroupType *gzgt,
wmGizmoMapType *gzmap_type);
void WM_gizmo_group_type_reinit_ptr(Main *bmain, wmGizmoGroupType *gzgt);
void WM_gizmo_group_type_reinit(Main *bmain, const char *idname);
void WM_gizmo_group_type_reinit(Main *bmain, blender::StringRef idname);
/* Utilities. */

View File

@@ -37,6 +37,8 @@
#include "wm_gizmo_intern.hh"
#include "wm_gizmo_wmapi.hh"
using blender::StringRef;
static void wm_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz);
/**
@@ -93,7 +95,7 @@ wmGizmo *WM_gizmo_new_ptr(const wmGizmoType *gzt, wmGizmoGroup *gzgroup, Pointer
return gz;
}
wmGizmo *WM_gizmo_new(const char *idname, wmGizmoGroup *gzgroup, PointerRNA *properties)
wmGizmo *WM_gizmo_new(const StringRef idname, wmGizmoGroup *gzgroup, PointerRNA *properties)
{
const wmGizmoType *gzt = WM_gizmotype_find(idname, false);
return WM_gizmo_new_ptr(gzt, gzgroup, properties);
@@ -584,7 +586,7 @@ void WM_gizmo_properties_create_ptr(PointerRNA *ptr, wmGizmoType *gzt)
*ptr = RNA_pointer_create_discrete(nullptr, gzt->srna, nullptr);
}
void WM_gizmo_properties_create(PointerRNA *ptr, const char *gtstring)
void WM_gizmo_properties_create(PointerRNA *ptr, const StringRef gtstring)
{
const wmGizmoType *gzt = WM_gizmotype_find(gtstring, false);
@@ -596,7 +598,7 @@ void WM_gizmo_properties_create(PointerRNA *ptr, const char *gtstring)
}
}
void WM_gizmo_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *gtstring)
void WM_gizmo_properties_alloc(PointerRNA **ptr, IDProperty **properties, const StringRef gtstring)
{
if (*properties == nullptr) {
*properties = blender::bke::idprop::create_group("wmOpItemProp").release();

View File

@@ -44,6 +44,8 @@
# include "BPY_extern.hh"
#endif
using blender::StringRef;
/* -------------------------------------------------------------------- */
/** \name wmGizmoGroup
* \{ */
@@ -939,18 +941,18 @@ wmGizmoGroupTypeRef *WM_gizmomaptype_group_find_ptr(wmGizmoMapType *gzmap_type,
return nullptr;
}
wmGizmoGroupTypeRef *WM_gizmomaptype_group_find(wmGizmoMapType *gzmap_type, const char *idname)
wmGizmoGroupTypeRef *WM_gizmomaptype_group_find(wmGizmoMapType *gzmap_type, const StringRef idname)
{
/* Could use hash lookups as operator types do, for now simple search. */
LISTBASE_FOREACH (wmGizmoGroupTypeRef *, gzgt_ref, &gzmap_type->grouptype_refs) {
if (STREQ(idname, gzgt_ref->type->idname)) {
if (idname == gzgt_ref->type->idname) {
return gzgt_ref;
}
}
return nullptr;
}
wmGizmoGroupTypeRef *WM_gizmomaptype_group_link(wmGizmoMapType *gzmap_type, const char *idname)
wmGizmoGroupTypeRef *WM_gizmomaptype_group_link(wmGizmoMapType *gzmap_type, const StringRef idname)
{
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
BLI_assert(gzgt != nullptr);
@@ -1119,7 +1121,7 @@ void WM_gizmo_group_type_add_ptr(wmGizmoGroupType *gzgt)
wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params);
WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type);
}
void WM_gizmo_group_type_add(const char *idname)
void WM_gizmo_group_type_add(const StringRef idname)
{
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
BLI_assert(gzgt != nullptr);
@@ -1140,7 +1142,7 @@ bool WM_gizmo_group_type_ensure_ptr(wmGizmoGroupType *gzgt)
wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params);
return WM_gizmo_group_type_ensure_ptr_ex(gzgt, gzmap_type);
}
bool WM_gizmo_group_type_ensure(const char *idname)
bool WM_gizmo_group_type_ensure(const StringRef idname)
{
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
BLI_assert(gzgt != nullptr);
@@ -1158,7 +1160,7 @@ void WM_gizmo_group_type_remove_ptr(Main *bmain, wmGizmoGroupType *gzgt)
wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params);
WM_gizmo_group_type_remove_ptr_ex(bmain, gzgt, gzmap_type);
}
void WM_gizmo_group_type_remove(Main *bmain, const char *idname)
void WM_gizmo_group_type_remove(Main *bmain, const StringRef idname)
{
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
BLI_assert(gzgt != nullptr);
@@ -1180,7 +1182,7 @@ void WM_gizmo_group_type_reinit_ptr(Main *bmain, wmGizmoGroupType *gzgt)
wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params);
WM_gizmo_group_type_reinit_ptr_ex(bmain, gzgt, gzmap_type);
}
void WM_gizmo_group_type_reinit(Main *bmain, const char *idname)
void WM_gizmo_group_type_reinit(Main *bmain, const StringRef idname)
{
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
BLI_assert(gzgt != nullptr);
@@ -1200,7 +1202,7 @@ void WM_gizmo_group_type_unlink_delayed_ptr(wmGizmoGroupType *gzgt)
WM_gizmo_group_type_unlink_delayed_ptr_ex(gzgt, gzmap_type);
}
void WM_gizmo_group_type_unlink_delayed(const char *idname)
void WM_gizmo_group_type_unlink_delayed(const StringRef idname)
{
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
BLI_assert(gzgt != nullptr);

View File

@@ -42,17 +42,15 @@ static auto &get_gizmo_group_type_map()
return map;
}
wmGizmoGroupType *WM_gizmogrouptype_find(const char *idname, bool quiet)
wmGizmoGroupType *WM_gizmogrouptype_find(const StringRef idname, bool quiet)
{
if (idname[0]) {
if (wmGizmoGroupType *const *gzgt = get_gizmo_group_type_map().lookup_key_ptr_as(
StringRef(idname)))
{
if (!idname.is_empty()) {
if (wmGizmoGroupType *const *gzgt = get_gizmo_group_type_map().lookup_key_ptr_as(idname)) {
return *gzgt;
}
if (!quiet) {
printf("search for unknown gizmo group '%s'\n", idname);
printf("search for unknown gizmo group '%s'\n", std::string(idname).c_str());
}
}
else {
@@ -150,9 +148,9 @@ void WM_gizmo_group_type_free_ptr(wmGizmoGroupType *gzgt)
/* XXX, TODO: update the world! */
}
bool WM_gizmo_group_type_free(const char *idname)
bool WM_gizmo_group_type_free(const StringRef idname)
{
wmGizmoGroupType *const *gzgt = get_gizmo_group_type_map().lookup_key_ptr_as(StringRef(idname));
wmGizmoGroupType *const *gzgt = get_gizmo_group_type_map().lookup_key_ptr_as(idname);
if (gzgt == nullptr) {
return false;
}

View File

@@ -51,15 +51,15 @@ static auto &get_gizmo_type_map()
return map;
}
const wmGizmoType *WM_gizmotype_find(const char *idname, bool quiet)
const wmGizmoType *WM_gizmotype_find(const StringRef idname, bool quiet)
{
if (idname[0]) {
if (wmGizmoType *const *gzt = get_gizmo_type_map().lookup_key_ptr_as(StringRef(idname))) {
if (!idname.is_empty()) {
if (wmGizmoType *const *gzt = get_gizmo_type_map().lookup_key_ptr_as(idname)) {
return *gzt;
}
if (!quiet) {
printf("search for unknown gizmo '%s'\n", idname);
printf("search for unknown gizmo '%s'\n", std::string(idname).c_str());
}
}
else {
@@ -159,9 +159,9 @@ void WM_gizmotype_remove_ptr(bContext *C, Main *bmain, wmGizmoType *gzt)
gizmotype_unlink(C, bmain, gzt);
}
bool WM_gizmotype_remove(bContext *C, Main *bmain, const char *idname)
bool WM_gizmotype_remove(bContext *C, Main *bmain, const StringRef idname)
{
wmGizmoType *const *gzt = get_gizmo_type_map().lookup_key_ptr_as(StringRef(idname));
wmGizmoType *const *gzt = get_gizmo_type_map().lookup_key_ptr_as(idname);
if (gzt == nullptr) {
return false;
}

View File

@@ -38,16 +38,16 @@ static auto &get_menu_type_map()
return map;
}
MenuType *WM_menutype_find(const char *idname, bool quiet)
MenuType *WM_menutype_find(const StringRef idname, bool quiet)
{
if (idname[0]) {
if (MenuType *const *mt = get_menu_type_map().lookup_key_ptr_as(StringRef(idname))) {
if (!idname.is_empty()) {
if (MenuType *const *mt = get_menu_type_map().lookup_key_ptr_as(idname)) {
return *mt;
}
}
if (!quiet) {
printf("search for unknown menutype %s\n", idname);
printf("search for unknown menutype %s\n", std::string(idname).c_str());
}
return nullptr;

View File

@@ -37,16 +37,16 @@ static auto &get_panel_type_map()
return map;
}
PanelType *WM_paneltype_find(const char *idname, bool quiet)
PanelType *WM_paneltype_find(const StringRef idname, bool quiet)
{
if (idname[0]) {
if (PanelType *const *pt = get_panel_type_map().lookup_key_ptr_as(StringRef(idname))) {
if (!idname.is_empty()) {
if (PanelType *const *pt = get_panel_type_map().lookup_key_ptr_as(idname)) {
return *pt;
}
}
if (!quiet) {
printf("search for unknown paneltype %s\n", idname);
printf("search for unknown paneltype %s\n", std::string(idname).c_str());
}
return nullptr;

View File

@@ -44,16 +44,16 @@ static auto &get_list_type_map()
return map;
}
uiListType *WM_uilisttype_find(const char *idname, bool quiet)
uiListType *WM_uilisttype_find(const StringRef idname, bool quiet)
{
if (idname[0]) {
if (uiListType *const *ult = get_list_type_map().lookup_key_ptr_as(StringRef(idname))) {
if (!idname.is_empty()) {
if (uiListType *const *ult = get_list_type_map().lookup_key_ptr_as(idname)) {
return *ult;
}
}
if (!quiet) {
printf("search for unknown uilisttype %s\n", idname);
printf("search for unknown uilisttype %s\n", std::string(idname).c_str());
}
return nullptr;