LibGUI: Register GUI icon path setters as write-only

The getters passed to REGISTER_STRING_PROPERTY are never invoked. But if
they were, they would errantly incur an implicit pointer-to-boolean cast
when their return type (Gfx::Bitmap*) is used to construct a JsonValue.
This commit is contained in:
Timothy Flynn 2022-12-08 11:00:55 -05:00 committed by Andreas Kling
parent 746364d7c1
commit 174062e0c5
Notes: sideshowbarker 2024-07-17 05:21:12 +09:00
3 changed files with 3 additions and 3 deletions

View file

@ -42,7 +42,7 @@ Button::Button(DeprecatedString text)
{ Gfx::ButtonStyle::Normal, "Normal" },
{ Gfx::ButtonStyle::Coolbar, "Coolbar" });
REGISTER_STRING_PROPERTY("icon", icon, set_icon_from_path);
REGISTER_WRITE_ONLY_STRING_PROPERTY("icon", set_icon_from_path);
REGISTER_BOOL_PROPERTY("default", is_default, set_default);
}

View file

@ -26,7 +26,7 @@ ImageWidget::ImageWidget(StringView)
REGISTER_BOOL_PROPERTY("auto_resize", auto_resize, set_auto_resize);
REGISTER_BOOL_PROPERTY("should_stretch", should_stretch, set_should_stretch);
REGISTER_STRING_PROPERTY("bitmap", bitmap, load_from_file);
REGISTER_WRITE_ONLY_STRING_PROPERTY("bitmap", load_from_file);
}
void ImageWidget::set_bitmap(Gfx::Bitmap const* bitmap)

View file

@ -34,7 +34,7 @@ Label::Label(DeprecatedString text)
REGISTER_STRING_PROPERTY("text", text, set_text);
REGISTER_BOOL_PROPERTY("autosize", is_autosize, set_autosize);
REGISTER_STRING_PROPERTY("icon", icon, set_icon_from_path);
REGISTER_WRITE_ONLY_STRING_PROPERTY("icon", set_icon_from_path);
}
void Label::set_autosize(bool autosize, size_t padding)