summaryrefslogtreecommitdiff
path: root/Applications/Spreadsheet
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2021-01-02 10:06:53 +0330
committerAndreas Kling <kling@serenityos.org>2021-01-02 17:15:46 +0100
commit4bc33ee3aedbb185af384675f856d9c718d7d01b (patch)
tree028dba0d3dd54a0d95b3d31cc99c33ef59247dc2 /Applications/Spreadsheet
parente080a4f74ae37d52e5d0c4223f99f220de5700aa (diff)
downloadserenity-4bc33ee3aedbb185af384675f856d9c718d7d01b.zip
Spreadsheet: Drop all references to example windows when closing them
Fixes #4716.
Diffstat (limited to 'Applications/Spreadsheet')
-rw-r--r--Applications/Spreadsheet/HelpWindow.cpp14
-rw-r--r--Applications/Spreadsheet/HelpWindow.h5
-rw-r--r--Applications/Spreadsheet/SpreadsheetWidget.cpp2
-rw-r--r--Applications/Spreadsheet/main.cpp2
4 files changed, 13 insertions, 10 deletions
diff --git a/Applications/Spreadsheet/HelpWindow.cpp b/Applications/Spreadsheet/HelpWindow.cpp
index 6aa6ff5c4d..a2534be02b 100644
--- a/Applications/Spreadsheet/HelpWindow.cpp
+++ b/Applications/Spreadsheet/HelpWindow.cpp
@@ -124,11 +124,13 @@ HelpWindow::HelpWindow(GUI::Window* parent)
return;
}
- auto dialog = GUI::Window::construct(this);
- dialog->resize(size());
- dialog->set_icon(icon());
- dialog->set_title(String::formatted("Spreadsheet Help - Example {} for {}", name, entry));
- auto& widget = dialog->set_main_widget<SpreadsheetWidget>(NonnullRefPtrVector<Sheet> {}, false);
+ auto window = GUI::Window::construct(this);
+ window->resize(size());
+ window->set_icon(icon());
+ window->set_title(String::formatted("Spreadsheet Help - Example {} for {}", name, entry));
+ window->on_close = [window = window.ptr()] { window->remove_from_parent(); };
+
+ auto& widget = window->set_main_widget<SpreadsheetWidget>(NonnullRefPtrVector<Sheet> {}, false);
auto sheet = Sheet::from_json(value.as_object(), widget.workbook());
if (!sheet) {
GUI::MessageBox::show_error(this, String::formatted("Corrupted example '{}' in '{}'", name, url.path()));
@@ -136,7 +138,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
}
widget.add_sheet(sheet.release_nonnull());
- dialog->show();
+ window->show();
} else if (url.host() == "doc") {
auto entry = LexicalPath(url.path()).basename();
m_webview->load(URL::create_with_data("text/html", render(entry)));
diff --git a/Applications/Spreadsheet/HelpWindow.h b/Applications/Spreadsheet/HelpWindow.h
index 53d486b554..1c02d90eed 100644
--- a/Applications/Spreadsheet/HelpWindow.h
+++ b/Applications/Spreadsheet/HelpWindow.h
@@ -27,6 +27,7 @@
#pragma once
#include <AK/JsonObject.h>
+#include <LibGUI/Dialog.h>
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
#include <LibWeb/OutOfProcessWebView.h>
@@ -37,12 +38,12 @@ class HelpWindow : public GUI::Window {
C_OBJECT(HelpWindow);
public:
- static NonnullRefPtr<HelpWindow> the()
+ static NonnullRefPtr<HelpWindow> the(GUI::Window* window)
{
if (s_the)
return *s_the;
- return *(s_the = adopt(*new HelpWindow));
+ return *(s_the = adopt(*new HelpWindow(window)));
}
virtual ~HelpWindow() override;
diff --git a/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Applications/Spreadsheet/SpreadsheetWidget.cpp
index 57056558c1..65e48e3f12 100644
--- a/Applications/Spreadsheet/SpreadsheetWidget.cpp
+++ b/Applications/Spreadsheet/SpreadsheetWidget.cpp
@@ -60,7 +60,7 @@ SpreadsheetWidget::SpreadsheetWidget(NonnullRefPtrVector<Sheet>&& sheets, bool s
help_button.set_fixed_size(20, 20);
help_button.on_click = [&](auto) {
auto docs = m_selected_view->sheet().gather_documentation();
- auto help_window = HelpWindow::the();
+ auto help_window = HelpWindow::the(window());
help_window->set_docs(move(docs));
help_window->show();
};
diff --git a/Applications/Spreadsheet/main.cpp b/Applications/Spreadsheet/main.cpp
index 0bfde24459..df806add79 100644
--- a/Applications/Spreadsheet/main.cpp
+++ b/Applications/Spreadsheet/main.cpp
@@ -236,7 +236,7 @@ int main(int argc, char* argv[])
help_menu.add_action(GUI::Action::create(
"Functions Help", [&](auto&) {
auto docs = spreadsheet_widget.current_worksheet().gather_documentation();
- auto help_window = Spreadsheet::HelpWindow::the();
+ auto help_window = Spreadsheet::HelpWindow::the(window);
help_window->set_docs(move(docs));
help_window->show();
},