mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:47:46 +00:00
LibGUI: Turn GUI::Application::the() into a pointer
During app teardown, the Application object may be destroyed before something else, and so having Application::the() return a reference was obscuring the truth about its lifetime. This patch makes the API more honest by returning a pointer. While this makes call sites look a bit more sketchy, do note that the global Application pointer only becomes null during app teardown.
This commit is contained in:
parent
f7577585a6
commit
ca93c22ae2
26 changed files with 51 additions and 49 deletions
|
@ -254,7 +254,7 @@ Tab::Tab()
|
|||
app_menu.add_action(*m_reload_action);
|
||||
app_menu.add_separator();
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the().quit();
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto& view_menu = m_menubar->add_menu("View");
|
||||
|
@ -429,7 +429,7 @@ void Tab::did_become_active()
|
|||
m_toolbar_container->set_visible(!is_fullscreen);
|
||||
m_statusbar->set_visible(!is_fullscreen);
|
||||
|
||||
GUI::Application::the().set_menubar(m_menubar);
|
||||
GUI::Application::the()->set_menubar(m_menubar);
|
||||
}
|
||||
|
||||
void Tab::context_menu_requested(const Gfx::IntPoint& screen_position)
|
||||
|
|
|
@ -69,7 +69,7 @@ int main(int argc, char** argv)
|
|||
|
||||
auto& app_menu = menubar->add_menu("Calculator");
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the().quit(0);
|
||||
GUI::Application::the()->quit();
|
||||
return;
|
||||
}));
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ int main(int argc, char** argv)
|
|||
}));
|
||||
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the().quit(0);
|
||||
GUI::Application::the()->quit();
|
||||
return;
|
||||
}));
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ void DisplaySettingsWidget::create_frame()
|
|||
ok_button.set_preferred_size(60, 22);
|
||||
ok_button.on_click = [this](auto) {
|
||||
send_settings_to_window_server();
|
||||
GUI::Application::the().quit();
|
||||
GUI::Application::the()->quit();
|
||||
};
|
||||
|
||||
auto& cancel_button = bottom_widget.add<GUI::Button>();
|
||||
|
@ -255,7 +255,7 @@ void DisplaySettingsWidget::create_frame()
|
|||
cancel_button.set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed);
|
||||
cancel_button.set_preferred_size(60, 22);
|
||||
cancel_button.on_click = [](auto) {
|
||||
GUI::Application::the().quit();
|
||||
GUI::Application::the()->quit();
|
||||
};
|
||||
|
||||
auto& apply_button = bottom_widget.add<GUI::Button>();
|
||||
|
|
|
@ -225,7 +225,7 @@ int run_in_desktop_mode(RefPtr<Core::ConfigFile> config, String initial_location
|
|||
};
|
||||
|
||||
window->show();
|
||||
return GUI::Application::the().exec();
|
||||
return GUI::Application::the()->exec();
|
||||
}
|
||||
|
||||
int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_location)
|
||||
|
@ -627,7 +627,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
|||
app_menu.add_action(properties_action);
|
||||
app_menu.add_separator();
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the().quit(0);
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto& view_menu = menubar->add_menu("View");
|
||||
|
@ -646,7 +646,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
|||
GUI::AboutDialog::show("File Manager", Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-folder.png"), window);
|
||||
}));
|
||||
|
||||
GUI::Application::the().set_menubar(move(menubar));
|
||||
GUI::Application::the()->set_menubar(move(menubar));
|
||||
|
||||
main_toolbar.add_action(go_back_action);
|
||||
main_toolbar.add_action(go_forward_action);
|
||||
|
@ -856,5 +856,5 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
|||
return GUI::Window::CloseRequestDecision::Close;
|
||||
};
|
||||
|
||||
return GUI::Application::the().exec();
|
||||
return GUI::Application::the()->exec();
|
||||
}
|
||||
|
|
|
@ -86,8 +86,8 @@ int main(int argc, char** argv)
|
|||
auto menubar = GUI::MenuBar::construct();
|
||||
|
||||
auto& app_menu = menubar->add_menu("Font Editor");
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the().quit(0);
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
app->quit();
|
||||
return;
|
||||
}));
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ int main(int argc, char* argv[])
|
|||
}));
|
||||
app_menu.add_separator();
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the().quit(0);
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto& go_menu = menubar->add_menu("Go");
|
||||
|
|
|
@ -142,7 +142,7 @@ HexEditorWidget::HexEditorWidget()
|
|||
app_menu.add_action(GUI::CommonActions::make_quit_action([this](auto&) {
|
||||
if (!request_close())
|
||||
return;
|
||||
GUI::Application::the().quit(0);
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
m_goto_decimal_offset_action = GUI::Action::create("Go To Offset (Decimal)...", { Mod_Ctrl | Mod_Shift, Key_G }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](const GUI::Action&) {
|
||||
|
@ -199,7 +199,7 @@ HexEditorWidget::HexEditorWidget()
|
|||
GUI::AboutDialog::show("Hex Editor", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-hexeditor.png"), window());
|
||||
}));
|
||||
|
||||
GUI::Application::the().set_menubar(move(menubar));
|
||||
GUI::Application::the()->set_menubar(move(menubar));
|
||||
|
||||
m_editor->set_focus(true);
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ void IRCAppWindow::setup_menus()
|
|||
auto& app_menu = menubar->add_menu("IRC Client");
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
dbgprintf("Terminal: Quit menu activated!\n");
|
||||
GUI::Application::the().quit(0);
|
||||
GUI::Application::the()->quit();
|
||||
return;
|
||||
}));
|
||||
|
||||
|
@ -301,7 +301,7 @@ void IRCAppWindow::setup_menus()
|
|||
GUI::AboutDialog::show("IRC Client", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-irc-client.png"), this);
|
||||
}));
|
||||
|
||||
GUI::Application::the().set_menubar(move(menubar));
|
||||
GUI::Application::the()->set_menubar(move(menubar));
|
||||
}
|
||||
|
||||
void IRCAppWindow::setup_widgets()
|
||||
|
|
|
@ -96,7 +96,7 @@ int main(int argc, char** argv)
|
|||
|
||||
auto& app_menu = menubar->add_menu("Piano");
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the().quit(0);
|
||||
GUI::Application::the()->quit();
|
||||
return;
|
||||
}));
|
||||
app_menu.add_action(GUI::Action::create("Export", { Mod_Ctrl, Key_E }, [&](const GUI::Action&) {
|
||||
|
|
|
@ -113,7 +113,7 @@ int main(int argc, char** argv)
|
|||
}));
|
||||
app_menu.add_separator();
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the().quit(0);
|
||||
GUI::Application::the()->quit();
|
||||
return;
|
||||
}));
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ int main(int argc, char** argv)
|
|||
auto menubar = GUI::MenuBar::construct();
|
||||
auto& app_menu = menubar->add_menu("System Monitor");
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the().quit(0);
|
||||
GUI::Application::the()->quit();
|
||||
return;
|
||||
}));
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ int main(int argc, char** argv)
|
|||
app_menu.add_separator();
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
dbgprintf("Terminal: Quit menu activated!\n");
|
||||
GUI::Application::the().quit(0);
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto& edit_menu = menubar->add_menu("Edit");
|
||||
|
|
|
@ -368,7 +368,7 @@ TextEditorWidget::TextEditorWidget()
|
|||
app_menu.add_action(GUI::CommonActions::make_quit_action([this](auto&) {
|
||||
if (!request_close())
|
||||
return;
|
||||
GUI::Application::the().quit(0);
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto& edit_menu = menubar->add_menu("Edit");
|
||||
|
@ -455,7 +455,7 @@ TextEditorWidget::TextEditorWidget()
|
|||
GUI::AboutDialog::show("Text Editor", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-texteditor.png"), window());
|
||||
}));
|
||||
|
||||
GUI::Application::the().set_menubar(move(menubar));
|
||||
GUI::Application::the()->set_menubar(move(menubar));
|
||||
|
||||
toolbar.add_action(*m_new_action);
|
||||
toolbar.add_action(*m_open_action);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue