mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibGUI: Let GWindow::set_main_widget() take ownership of the widget
We were already doing this anyway, with ~GWindow() calling delete on the main widget.
This commit is contained in:
parent
fc6bd52e0d
commit
dc572e31fa
Notes:
sideshowbarker
2024-07-19 12:36:51 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/dc572e31fa7
1 changed files with 3 additions and 3 deletions
|
@ -36,10 +36,7 @@ GWindow::GWindow(CObject* parent)
|
|||
GWindow::~GWindow()
|
||||
{
|
||||
all_windows.remove(this);
|
||||
if (m_main_widget)
|
||||
delete m_main_widget;
|
||||
hide();
|
||||
|
||||
if (all_windows.is_empty()) {
|
||||
GApplication::the().did_delete_last_window({});
|
||||
}
|
||||
|
@ -465,8 +462,11 @@ void GWindow::set_main_widget(GWidget* widget)
|
|||
{
|
||||
if (m_main_widget == widget)
|
||||
return;
|
||||
if (m_main_widget)
|
||||
remove_child(*m_main_widget);
|
||||
m_main_widget = widget;
|
||||
if (m_main_widget) {
|
||||
add_child(*widget);
|
||||
auto new_window_rect = rect();
|
||||
if (m_main_widget->horizontal_size_policy() == SizePolicy::Fixed)
|
||||
new_window_rect.set_width(m_main_widget->preferred_size().width());
|
||||
|
|
Loading…
Add table
Reference in a new issue