mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 01:35:08 +00:00
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.
This commit is contained in:
parent
dfa69b82b4
commit
b29ff7b821
18 changed files with 43 additions and 43 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue