mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 05:27:35 +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
|
@ -175,10 +175,10 @@ int main(int argc, char** argv)
|
|||
};
|
||||
|
||||
auto new_action = GUI::Action::create("Add new file to project...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) {
|
||||
auto& input_box = g_window->add<GUI::InputBox>("Enter name of new file:", "Add new file to project");
|
||||
if (input_box.exec() == GUI::InputBox::ExecCancel)
|
||||
auto input_box = GUI::InputBox::construct("Enter name of new file:", "Add new file to project", g_window);
|
||||
if (input_box->exec() == GUI::InputBox::ExecCancel)
|
||||
return;
|
||||
auto filename = input_box.text_value();
|
||||
auto filename = input_box->text_value();
|
||||
auto file = Core::File::construct(filename);
|
||||
if (!file->open((Core::IODevice::OpenMode)(Core::IODevice::WriteOnly | Core::IODevice::MustBeNew))) {
|
||||
GUI::MessageBox::show(String::format("Failed to create '%s'", filename.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue