diff --git a/Applications/PaintBrush/ColorDialog.cpp b/Applications/PaintBrush/ColorDialog.cpp index c05c24dd8b1..703c2c7fc36 100644 --- a/Applications/PaintBrush/ColorDialog.cpp +++ b/Applications/PaintBrush/ColorDialog.cpp @@ -53,7 +53,7 @@ void ColorDialog::build() }; auto make_spinbox = [&](RGBComponent component, int initial_value) { - auto* spinbox = new GSpinBox(left_vertical_container); + auto spinbox = GSpinBox::construct(left_vertical_container); spinbox->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); spinbox->set_preferred_size(0, 20); spinbox->set_min(0); diff --git a/Demos/WidgetGallery/main.cpp b/Demos/WidgetGallery/main.cpp index f26372ed222..64cbe9657de 100755 --- a/Demos/WidgetGallery/main.cpp +++ b/Demos/WidgetGallery/main.cpp @@ -61,9 +61,9 @@ int main(int argc, char** argv) textbox2->set_text("GTextBox 2"); textbox2->set_enabled(false); - auto* spinbox1 = new GSpinBox(main_widget); + auto spinbox1 = GSpinBox::construct(main_widget); (void)spinbox1; - auto* spinbox2 = new GSpinBox(main_widget); + auto spinbox2 = GSpinBox::construct(main_widget); spinbox2->set_enabled(false); auto* vertical_slider_container = new GWidget(main_widget); diff --git a/DevTools/VisualBuilder/VBWidgetRegistry.cpp b/DevTools/VisualBuilder/VBWidgetRegistry.cpp index 86b68b91590..3852a9b9d9d 100644 --- a/DevTools/VisualBuilder/VBWidgetRegistry.cpp +++ b/DevTools/VisualBuilder/VBWidgetRegistry.cpp @@ -89,7 +89,7 @@ static GWidget* build_gwidget(VBWidgetType type, GWidget* parent) return button; } case VBWidgetType::GSpinBox: { - auto* box = new GSpinBox(parent); + auto box = GSpinBox::construct(parent); box->set_range(0, 100); box->set_value(0); return box; diff --git a/Libraries/LibGUI/GSpinBox.h b/Libraries/LibGUI/GSpinBox.h index 476e406cac5..009bc99f00e 100644 --- a/Libraries/LibGUI/GSpinBox.h +++ b/Libraries/LibGUI/GSpinBox.h @@ -8,7 +8,6 @@ class GTextEditor; class GSpinBox : public GWidget { C_OBJECT(GSpinBox) public: - GSpinBox(GWidget* parent = nullptr); virtual ~GSpinBox() override; int value() const { return m_value; } @@ -23,6 +22,8 @@ public: Function on_change; protected: + explicit GSpinBox(GWidget* parent = nullptr); + virtual void resize_event(GResizeEvent&) override; private: