summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-04 20:53:51 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-04 21:04:06 +0100
commitb29ff7b821ba4752a797d610c8f41d1a20f83d86 (patch)
treea1f848e7e7d3d7c97c05331cad8ea3f9037e5cb6 /Libraries
parentdfa69b82b4233494e65af53bdd620ab33e0c043a (diff)
downloadserenity-b29ff7b821ba4752a797d610c8f41d1a20f83d86.zip
LibGUI: Don't use Core::Object::add() to instantiate dialogs
Now that add() returns a WidgetType&, we can't rely on the parent of a GUI::Dialog to still keep it alive after exec() returns. This happens because exec() will call remove_from_parent() on itself before returning. And so we go back to the old idiom for creating a GUI::Dialog centered above a specific window. Just call GUI::Dialog::construct(), passing the "parent" window as the last parameter.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGUI/AboutDialog.cpp4
-rw-r--r--Libraries/LibGUI/AboutDialog.h6
-rw-r--r--Libraries/LibGUI/ColorPicker.cpp4
-rw-r--r--Libraries/LibGUI/ColorPicker.h2
-rw-r--r--Libraries/LibGUI/Dialog.cpp4
-rw-r--r--Libraries/LibGUI/Dialog.h2
-rw-r--r--Libraries/LibGUI/FilePicker.cpp4
-rw-r--r--Libraries/LibGUI/FilePicker.h2
-rw-r--r--Libraries/LibGUI/InputBox.cpp4
-rw-r--r--Libraries/LibGUI/InputBox.h2
-rw-r--r--Libraries/LibGUI/MessageBox.cpp10
-rw-r--r--Libraries/LibGUI/MessageBox.h4
12 files changed, 24 insertions, 24 deletions
diff --git a/Libraries/LibGUI/AboutDialog.cpp b/Libraries/LibGUI/AboutDialog.cpp
index 12b43c3f40..9fe9f836bf 100644
--- a/Libraries/LibGUI/AboutDialog.cpp
+++ b/Libraries/LibGUI/AboutDialog.cpp
@@ -33,8 +33,8 @@
namespace GUI {
-AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Core::Object* parent)
- : Dialog(parent)
+AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window* parent_window)
+ : Dialog(parent_window)
, m_name(name)
, m_icon(icon)
{
diff --git a/Libraries/LibGUI/AboutDialog.h b/Libraries/LibGUI/AboutDialog.h
index 265f8c2fa0..562f404c17 100644
--- a/Libraries/LibGUI/AboutDialog.h
+++ b/Libraries/LibGUI/AboutDialog.h
@@ -35,14 +35,14 @@ class AboutDialog final : public Dialog {
public:
virtual ~AboutDialog() override;
- static void show(const StringView& name, const Gfx::Bitmap* icon = nullptr, Core::Object* parent = nullptr)
+ static void show(const StringView& name, const Gfx::Bitmap* icon = nullptr, Window* parent_window = nullptr)
{
- auto dialog = AboutDialog::construct(name, icon, parent);
+ auto dialog = AboutDialog::construct(name, icon, parent_window);
dialog->exec();
}
private:
- AboutDialog(const StringView& name, const Gfx::Bitmap* icon = nullptr, Core::Object* parent = nullptr);
+ AboutDialog(const StringView& name, const Gfx::Bitmap* icon = nullptr, Window* parent_window = nullptr);
String m_name;
RefPtr<Gfx::Bitmap> m_icon;
diff --git a/Libraries/LibGUI/ColorPicker.cpp b/Libraries/LibGUI/ColorPicker.cpp
index 7640812a5b..e58059481e 100644
--- a/Libraries/LibGUI/ColorPicker.cpp
+++ b/Libraries/LibGUI/ColorPicker.cpp
@@ -34,8 +34,8 @@
namespace GUI {
-ColorPicker::ColorPicker(Color color, Core::Object* parent)
- : Dialog(parent)
+ColorPicker::ColorPicker(Color color, Window* parent_window)
+ : Dialog(parent_window)
, m_color(color)
{
set_title("Edit Color");
diff --git a/Libraries/LibGUI/ColorPicker.h b/Libraries/LibGUI/ColorPicker.h
index d4d3548f1e..3aeea23384 100644
--- a/Libraries/LibGUI/ColorPicker.h
+++ b/Libraries/LibGUI/ColorPicker.h
@@ -38,7 +38,7 @@ public:
Color color() const { return m_color; }
private:
- explicit ColorPicker(Color, Core::Object* parent = nullptr);
+ explicit ColorPicker(Color, Window* parent_window = nullptr);
void build();
diff --git a/Libraries/LibGUI/Dialog.cpp b/Libraries/LibGUI/Dialog.cpp
index 9c4468b112..491fbfb8d0 100644
--- a/Libraries/LibGUI/Dialog.cpp
+++ b/Libraries/LibGUI/Dialog.cpp
@@ -31,8 +31,8 @@
namespace GUI {
-Dialog::Dialog(Core::Object* parent)
- : Window(parent)
+Dialog::Dialog(Window* parent_window)
+ : Window(parent_window)
{
set_modal(true);
}
diff --git a/Libraries/LibGUI/Dialog.h b/Libraries/LibGUI/Dialog.h
index 10de2981a5..857177d64c 100644
--- a/Libraries/LibGUI/Dialog.h
+++ b/Libraries/LibGUI/Dialog.h
@@ -53,7 +53,7 @@ public:
virtual void close() override;
protected:
- explicit Dialog(Core::Object* parent);
+ explicit Dialog(Window* parent_window);
private:
OwnPtr<Core::EventLoop> m_event_loop;
diff --git a/Libraries/LibGUI/FilePicker.cpp b/Libraries/LibGUI/FilePicker.cpp
index 3936f038fe..575fb47c29 100644
--- a/Libraries/LibGUI/FilePicker.cpp
+++ b/Libraries/LibGUI/FilePicker.cpp
@@ -74,8 +74,8 @@ Optional<String> FilePicker::get_save_filepath(const String& title, const String
return {};
}
-FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView& path, Core::Object* parent)
- : Dialog(parent)
+FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView& path, Window* parent_window)
+ : Dialog(parent_window)
, m_model(FileSystemModel::create())
, m_mode(mode)
{
diff --git a/Libraries/LibGUI/FilePicker.h b/Libraries/LibGUI/FilePicker.h
index 2fc98b2a04..99d577d721 100644
--- a/Libraries/LibGUI/FilePicker.h
+++ b/Libraries/LibGUI/FilePicker.h
@@ -52,7 +52,7 @@ private:
void clear_preview();
void on_file_return();
- FilePicker(Mode type = Mode::Open, const StringView& file_name = "Untitled", const StringView& path = String(get_current_user_home_path()), Core::Object* parent = nullptr);
+ FilePicker(Mode type = Mode::Open, const StringView& file_name = "Untitled", const StringView& path = String(get_current_user_home_path()), Window* parent_window = nullptr);
static String ok_button_name(Mode mode)
{
diff --git a/Libraries/LibGUI/InputBox.cpp b/Libraries/LibGUI/InputBox.cpp
index aada52ddcb..7a0a22918d 100644
--- a/Libraries/LibGUI/InputBox.cpp
+++ b/Libraries/LibGUI/InputBox.cpp
@@ -34,8 +34,8 @@
namespace GUI {
-InputBox::InputBox(const StringView& prompt, const StringView& title, Core::Object* parent)
- : Dialog(parent)
+InputBox::InputBox(const StringView& prompt, const StringView& title, GUI::Window* parent_window)
+ : Dialog(parent_window)
, m_prompt(prompt)
{
set_title(title);
diff --git a/Libraries/LibGUI/InputBox.h b/Libraries/LibGUI/InputBox.h
index 1d0bd47e24..4df9917eee 100644
--- a/Libraries/LibGUI/InputBox.h
+++ b/Libraries/LibGUI/InputBox.h
@@ -33,7 +33,7 @@ namespace GUI {
class InputBox : public Dialog {
C_OBJECT(InputBox)
public:
- explicit InputBox(const StringView& prompt, const StringView& title, Core::Object* parent = nullptr);
+ explicit InputBox(const StringView& prompt, const StringView& title, Window* parent_window = nullptr);
virtual ~InputBox() override;
String text_value() const { return m_text_value; }
diff --git a/Libraries/LibGUI/MessageBox.cpp b/Libraries/LibGUI/MessageBox.cpp
index 952ace264c..750f1ccaaa 100644
--- a/Libraries/LibGUI/MessageBox.cpp
+++ b/Libraries/LibGUI/MessageBox.cpp
@@ -33,16 +33,16 @@
namespace GUI {
-int MessageBox::show(const StringView& text, const StringView& title, Type type, InputType input_type, Core::Object* parent)
+int MessageBox::show(const StringView& text, const StringView& title, Type type, InputType input_type, Window* parent_window)
{
auto box = MessageBox::construct(text, title, type, input_type);
- if (parent)
- parent->add_child(box);
+ if (parent_window)
+ parent_window->add_child(box);
return box->exec();
}
-MessageBox::MessageBox(const StringView& text, const StringView& title, Type type, InputType input_type, Core::Object* parent)
- : Dialog(parent)
+MessageBox::MessageBox(const StringView& text, const StringView& title, Type type, InputType input_type, Window* parent_window)
+ : Dialog(parent_window)
, m_text(text)
, m_type(type)
, m_input_type(input_type)
diff --git a/Libraries/LibGUI/MessageBox.h b/Libraries/LibGUI/MessageBox.h
index bcf7232774..0d7ea6f96e 100644
--- a/Libraries/LibGUI/MessageBox.h
+++ b/Libraries/LibGUI/MessageBox.h
@@ -49,10 +49,10 @@ public:
virtual ~MessageBox() override;
- static int show(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, Core::Object* parent = nullptr);
+ static int show(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, Window* parent_window = nullptr);
private:
- explicit MessageBox(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, Core::Object* parent = nullptr);
+ explicit MessageBox(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, Window* parent_window = nullptr);
bool should_include_ok_button() const;
bool should_include_cancel_button() const;