summaryrefslogtreecommitdiff
path: root/Applications/FileManager
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 /Applications/FileManager
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 'Applications/FileManager')
-rw-r--r--Applications/FileManager/PropertiesDialog.cpp4
-rw-r--r--Applications/FileManager/PropertiesDialog.h2
-rw-r--r--Applications/FileManager/main.cpp6
3 files changed, 6 insertions, 6 deletions
diff --git a/Applications/FileManager/PropertiesDialog.cpp b/Applications/FileManager/PropertiesDialog.cpp
index 3f3c09be4d..8101c52539 100644
--- a/Applications/FileManager/PropertiesDialog.cpp
+++ b/Applications/FileManager/PropertiesDialog.cpp
@@ -36,8 +36,8 @@
#include <stdio.h>
#include <unistd.h>
-PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, bool disable_rename, Core::Object* parent)
- : Dialog(parent)
+PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, bool disable_rename, Window* parent_window)
+ : Dialog(parent_window)
, m_model(model)
{
auto file_path = FileSystemPath(path);
diff --git a/Applications/FileManager/PropertiesDialog.h b/Applications/FileManager/PropertiesDialog.h
index 08f2969894..69e23a820f 100644
--- a/Applications/FileManager/PropertiesDialog.h
+++ b/Applications/FileManager/PropertiesDialog.h
@@ -40,7 +40,7 @@ public:
virtual ~PropertiesDialog() override;
private:
- PropertiesDialog(GUI::FileSystemModel&, String, bool disable_rename, Core::Object* parent = nullptr);
+ PropertiesDialog(GUI::FileSystemModel&, String, bool disable_rename, Window* parent = nullptr);
struct PropertyValuePair {
String property;
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp
index bc96ca6735..d035abef55 100644
--- a/Applications/FileManager/main.cpp
+++ b/Applications/FileManager/main.cpp
@@ -171,12 +171,12 @@ int main(int argc, char** argv)
});
auto mkdir_action = GUI::Action::create("New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) {
- auto& input_box = window->add<GUI::InputBox>("Enter name:", "New directory");
- if (input_box.exec() == GUI::InputBox::ExecOK && !input_box.text_value().is_empty()) {
+ auto input_box = GUI::InputBox::construct("Enter name:", "New directory", window);
+ if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) {
auto new_dir_path = canonicalized_path(
String::format("%s/%s",
directory_view.path().characters(),
- input_box.text_value().characters()));
+ input_box->text_value().characters()));
int rc = mkdir(new_dir_path.characters(), 0777);
if (rc < 0) {
GUI::MessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window);