mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 20:25:07 +00:00
LibCore: Make CObject reference-counted
Okay, I've spent a whole day on this now, and it finally kinda works! With this patch, CObject and all of its derived classes are reference counted instead of tree-owned. The previous, Qt-like model was nice and familiar, but ultimately also outdated and difficult to reason about. CObject-derived types should now be stored in RefPtr/NonnullRefPtr and each class can be constructed using the forwarding construct() helper: auto widget = GWidget::construct(parent_widget); Note that construct() simply forwards all arguments to an existing constructor. It is inserted into each class by the C_OBJECT macro, see CObject.h to understand how that works. CObject::delete_later() disappears in this patch, as there is no longer a single logical owner of a CObject.
This commit is contained in:
parent
0c72e0c09f
commit
bc319d9e88
45 changed files with 174 additions and 233 deletions
|
@ -57,11 +57,11 @@ GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringVie
|
|||
horizontal_container->set_fill_with_background_color(true);
|
||||
horizontal_container->set_background_color(Color::WarmGray);
|
||||
|
||||
auto vertical_container = GWidget::construct(horizontal_container);
|
||||
auto vertical_container = GWidget::construct(horizontal_container.ptr());
|
||||
vertical_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
vertical_container->layout()->set_spacing(4);
|
||||
|
||||
auto upper_container = GWidget::construct(vertical_container);
|
||||
auto upper_container = GWidget::construct(vertical_container.ptr());
|
||||
upper_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
upper_container->layout()->set_spacing(4);
|
||||
upper_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
|
@ -118,13 +118,13 @@ GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringVie
|
|||
});
|
||||
toolbar->add_action(*mkdir_action);
|
||||
|
||||
auto lower_container = GWidget::construct(vertical_container);
|
||||
auto lower_container = GWidget::construct(vertical_container.ptr());
|
||||
lower_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
lower_container->layout()->set_spacing(4);
|
||||
lower_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
lower_container->set_preferred_size(0, 60);
|
||||
|
||||
auto filename_container = GWidget::construct(lower_container);
|
||||
auto filename_container = GWidget::construct(lower_container.ptr());
|
||||
filename_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
filename_container->set_preferred_size(0, 20);
|
||||
filename_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
|
@ -132,7 +132,7 @@ GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringVie
|
|||
filename_label->set_text_alignment(TextAlignment::CenterLeft);
|
||||
filename_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
filename_label->set_preferred_size(60, 0);
|
||||
m_filename_textbox = GTextBox::construct(filename_container);
|
||||
m_filename_textbox = GTextBox::construct(filename_container.ptr());
|
||||
if (m_mode == Mode::Save) {
|
||||
m_filename_textbox->set_text(file_name);
|
||||
m_filename_textbox->set_focus(true);
|
||||
|
@ -155,7 +155,7 @@ GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringVie
|
|||
set_preview(path);
|
||||
};
|
||||
|
||||
auto button_container = GWidget::construct(lower_container);
|
||||
auto button_container = GWidget::construct(lower_container.ptr());
|
||||
button_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
button_container->set_preferred_size(0, 20);
|
||||
button_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue