Skip to content

Commit

Permalink
UI/Qt: Pass WebContentOptions to TaskManagerWindow constructor
Browse files Browse the repository at this point in the history
Previously, the browser would crash when opening a task manager window
with the `--enable-qt-networking` flag set because we were passing the
default WebContentOptions to the underlying WebContentView.
  • Loading branch information
tcl3 authored and kalenikaliaksandr committed Jul 10, 2024
1 parent 28b95e8 commit 1103908
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Ladybird/Qt/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ ErrorOr<void> Application::initialize_image_decoder()
return {};
}

void Application::show_task_manager_window()
void Application::show_task_manager_window(WebContentOptions const& web_content_options)
{
if (!m_task_manager_window) {
m_task_manager_window = new TaskManagerWindow(nullptr);
m_task_manager_window = new TaskManagerWindow(nullptr, web_content_options);
}
m_task_manager_window->show();
m_task_manager_window->activateWindow();
Expand Down
2 changes: 1 addition & 1 deletion Ladybird/Qt/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Application : public QApplication {

BrowserWindow& new_window(Vector<URL::URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path, bool allow_popups, Tab* parent_tab = nullptr, Optional<u64> page_index = {});

void show_task_manager_window();
void show_task_manager_window(WebContentOptions const&);
void close_task_manager_window();

BrowserWindow& active_window() { return *m_active_window; }
Expand Down
4 changes: 2 additions & 2 deletions Ladybird/Qt/BrowserWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::Cook
task_manager_action->setIcon(load_icon_from_uri("resource://icons/16x16/app-system-monitor.png"sv));
task_manager_action->setShortcuts({ QKeySequence("Ctrl+Shift+M") });
inspect_menu->addAction(task_manager_action);
QObject::connect(task_manager_action, &QAction::triggered, this, [] {
static_cast<Ladybird::Application*>(QApplication::instance())->show_task_manager_window();
QObject::connect(task_manager_action, &QAction::triggered, this, [&] {
static_cast<Ladybird::Application*>(QApplication::instance())->show_task_manager_window(m_web_content_options);
});

auto* debug_menu = m_hamburger_menu->addMenu("&Debug");
Expand Down
4 changes: 2 additions & 2 deletions Ladybird/Qt/TaskManagerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

namespace Ladybird {

TaskManagerWindow::TaskManagerWindow(QWidget* parent)
TaskManagerWindow::TaskManagerWindow(QWidget* parent, WebContentOptions const& web_content_options)
: QWidget(parent, Qt::WindowFlags(Qt::WindowType::Window))
, m_web_view(new WebContentView(this, {}, {}))
, m_web_view(new WebContentView(this, web_content_options, {}))
{
setLayout(new QVBoxLayout);
layout()->addWidget(m_web_view);
Expand Down
2 changes: 1 addition & 1 deletion Ladybird/Qt/TaskManagerWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TaskManagerWindow : public QWidget {
Q_OBJECT

public:
explicit TaskManagerWindow(QWidget* parent);
TaskManagerWindow(QWidget* parent, WebContentOptions const&);

private:
virtual void showEvent(QShowEvent*) override;
Expand Down

0 comments on commit 1103908

Please sign in to comment.