summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-08-18 12:17:09 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-08-18 12:18:17 +0200
commitdc572e31fa7f44319f01fc35f35df508e03beaba (patch)
tree0f6cdad68c6e394eadbb773e3c327bdba13c9164 /Libraries
parentfc6bd52e0da7ed67bfae273eb2dddaa66018837a (diff)
downloadserenity-dc572e31fa7f44319f01fc35f35df508e03beaba.zip
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.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGUI/GWindow.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Libraries/LibGUI/GWindow.cpp b/Libraries/LibGUI/GWindow.cpp
index fca5721b71..b71b9d4dd4 100644
--- a/Libraries/LibGUI/GWindow.cpp
+++ b/Libraries/LibGUI/GWindow.cpp
@@ -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());