From 6c73fdf8d115f1930a31d93279b1e2cf110d72cd Mon Sep 17 00:00:00 2001 From: Itamar Date: Thu, 24 Sep 2020 22:43:17 +0300 Subject: [PATCH] HackStudio: Fix FormEditor widget icons loading Previously, when resolving the paths for the FormEditor widget icons we didn't take into the account that calling class_name() returns the widget name with a "GUI::" prefix. Also, we now skip over widgets that we don't have an icon for. --- DevTools/HackStudio/HackStudioWidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DevTools/HackStudio/HackStudioWidget.cpp b/DevTools/HackStudio/HackStudioWidget.cpp index bcd299e9ab..6d415976f8 100644 --- a/DevTools/HackStudio/HackStudioWidget.cpp +++ b/DevTools/HackStudio/HackStudioWidget.cpp @@ -677,7 +677,10 @@ void HackStudioWidget::create_form_editor(GUI::Widget& parent) form_widgets_toolbar.add_action(cursor_tool_action); GUI::WidgetClassRegistration::for_each([&, this](const GUI::WidgetClassRegistration& reg) { - auto icon_path = String::format("/res/icons/hackstudio/G%s.png", reg.class_name().characters()); + constexpr size_t gui_namespace_prefix_length = sizeof("GUI::") - 1; + auto icon_path = String::format("/res/icons/hackstudio/G%s.png", reg.class_name().substring(gui_namespace_prefix_length, reg.class_name().length() - gui_namespace_prefix_length).characters()); + if (!Core::File::exists(icon_path)) + return; auto action = GUI::Action::create_checkable(reg.class_name(), Gfx::Bitmap::load_from_file(icon_path), [®, this](auto&) { m_form_editor_widget->set_tool(make(*m_form_editor_widget, reg)); auto widget = reg.construct();