mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:07:34 +00:00
LibGUI: Don't create GMessageBox and GInputBox on the stack
We need to get rid of all instances of widgets-on-the-stack since that will no longer work in the ref-counting world.
This commit is contained in:
parent
defafd72bc
commit
31b38ed88f
7 changed files with 30 additions and 33 deletions
|
@ -102,11 +102,11 @@ GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringVie
|
|||
toolbar->add_separator();
|
||||
|
||||
auto mkdir_action = GAction::create("New directory...", GraphicsBitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this](const GAction&) {
|
||||
GInputBox input_box("Enter name:", "New directory", this);
|
||||
if (input_box.exec() == GInputBox::ExecOK && !input_box.text_value().is_empty()) {
|
||||
auto input_box = GInputBox::construct("Enter name:", "New directory", this);
|
||||
if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty()) {
|
||||
auto new_dir_path = FileSystemPath(String::format("%s/%s",
|
||||
m_model->path().characters(),
|
||||
input_box.text_value().characters()))
|
||||
input_box->text_value().characters()))
|
||||
.string();
|
||||
int rc = mkdir(new_dir_path.characters(), 0777);
|
||||
if (rc < 0) {
|
||||
|
@ -248,8 +248,8 @@ void GFilePicker::on_file_return()
|
|||
FileSystemPath path(String::format("%s/%s", m_model->path().characters(), m_filename_textbox->text().characters()));
|
||||
|
||||
if (GFilePicker::file_exists(path.string()) && m_mode == Mode::Save) {
|
||||
GMessageBox box("File already exists, overwrite?", "Existing File", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel);
|
||||
if (box.exec() == GMessageBox::ExecCancel)
|
||||
auto result = GMessageBox::show("File already exists, overwrite?", "Existing File", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel);
|
||||
if (result == GMessageBox::ExecCancel)
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
#include <LibGUI/GMessageBox.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void GMessageBox::show(const StringView& text, const StringView& title, Type type, InputType input_type, CObject* parent)
|
||||
int GMessageBox::show(const StringView& text, const StringView& title, Type type, InputType input_type, CObject* parent)
|
||||
{
|
||||
GMessageBox box(text, title, type, input_type, parent);
|
||||
box.exec();
|
||||
auto box = GMessageBox::construct(text, title, type, input_type, parent);
|
||||
return box->exec();
|
||||
}
|
||||
|
||||
GMessageBox::GMessageBox(const StringView& text, const StringView& title, Type type, InputType input_type, CObject* parent)
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
explicit GMessageBox(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, CObject* parent = nullptr);
|
||||
virtual ~GMessageBox() override;
|
||||
|
||||
static void show(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, CObject* parent = nullptr);
|
||||
static int show(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, CObject* parent = nullptr);
|
||||
|
||||
private:
|
||||
bool should_include_ok_button() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue