mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:37:45 +00:00
Browser: Close inspectors and JS console when tab closes
Keeping these around can lead to use-after-frees and crashes.
This commit is contained in:
parent
9dea61e095
commit
e3ad5731f7
2 changed files with 20 additions and 1 deletions
|
@ -42,6 +42,11 @@
|
|||
|
||||
namespace Browser {
|
||||
|
||||
Tab::~Tab()
|
||||
{
|
||||
close_sub_widgets();
|
||||
}
|
||||
|
||||
URL url_from_user_input(DeprecatedString const& input)
|
||||
{
|
||||
if (input.starts_with('?') && !g_search_engine.is_empty())
|
||||
|
@ -674,6 +679,19 @@ void Tab::show_inspector_window(Browser::Tab::InspectorTarget inspector_target)
|
|||
window->move_to_front();
|
||||
}
|
||||
|
||||
void Tab::close_sub_widgets()
|
||||
{
|
||||
auto close_widget_window = [](auto& widget) {
|
||||
if (widget) {
|
||||
auto* window = widget->window();
|
||||
window->close();
|
||||
}
|
||||
};
|
||||
close_widget_window(m_dom_inspector_widget);
|
||||
close_widget_window(m_console_widget);
|
||||
close_widget_window(m_storage_widget);
|
||||
}
|
||||
|
||||
void Tab::show_console_window()
|
||||
{
|
||||
if (!m_console_widget) {
|
||||
|
|
|
@ -34,7 +34,7 @@ class Tab final : public GUI::Widget {
|
|||
friend class BrowserWindow;
|
||||
|
||||
public:
|
||||
virtual ~Tab() override = default;
|
||||
virtual ~Tab() override;
|
||||
|
||||
URL url() const;
|
||||
|
||||
|
@ -106,6 +106,7 @@ private:
|
|||
void start_download(const URL& url);
|
||||
void view_source(const URL& url, DeprecatedString const& source);
|
||||
void update_status(Optional<DeprecatedString> text_override = {}, i32 count_waiting = 0);
|
||||
void close_sub_widgets();
|
||||
|
||||
enum class MayAppendTLD {
|
||||
No,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue