1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 13:47:46 +00:00

LibGUI: Make Application's construction fallible

The pattern to construct `Application` was to use the `try_create`
method from the `C_OBJECT` macro. While being safe from an OOM
perspective, this method doesn't propagate errors from the constructor.
This patch make `Application` use the `C_OBJECT_ABSTRACT` and manually
define a `create` method that can bubble up errors from the
construction stage.

This commit also removes the ability to use `argc` and `argv` to
create an `Application`, only `Main`'s `Arguments` can be used.

From a user point of view, the patch renames `try_create` => `create`,
hence the huge number of modified files.
This commit is contained in:
Lucas CHOLLET 2023-05-05 00:24:53 -04:00 committed by Sam Atkins
parent f132751fae
commit 1a97382305
93 changed files with 121 additions and 118 deletions

View file

@ -33,7 +33,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
srand(time(nullptr));
auto app = TRY(GUI::Application::try_create(arguments));
auto app = TRY(GUI::Application::create(arguments));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-2048"sv));
auto window = TRY(GUI::Window::try_create());

View file

@ -23,7 +23,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath recvfd sendfd unix"));
auto app = TRY(GUI::Application::try_create(arguments));
auto app = TRY(GUI::Application::create(arguments));
auto const app_name = "BrickGame"sv;
auto const title = "Brick Game"sv;

View file

@ -53,7 +53,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath recvfd sendfd thread proc exec unix"));
auto app = TRY(GUI::Application::try_create(arguments));
auto app = TRY(GUI::Application::create(arguments));
Config::pledge_domain("Games");
Config::monitor_domain("Games");

View file

@ -22,7 +22,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath recvfd sendfd unix"));
auto app = TRY(GUI::Application::try_create(arguments));
auto app = TRY(GUI::Application::create(arguments));
auto const app_name = "ColorLines"sv;
auto const title = "Color Lines"sv;

View file

@ -21,7 +21,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath recvfd sendfd unix"));
auto app = TRY(GUI::Application::try_create(arguments));
auto app = TRY(GUI::Application::create(arguments));
Config::pledge_domain("FlappyBug");

View file

@ -56,7 +56,7 @@ static int get_number_of_moves_from_ai(Board const& board)
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath recvfd sendfd unix"));
auto app = TRY(GUI::Application::try_create(arguments));
auto app = TRY(GUI::Application::create(arguments));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-flood"sv));
auto window = TRY(GUI::Window::try_create());

View file

@ -30,7 +30,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath recvfd sendfd unix"));
auto app = TRY(GUI::Application::try_create(arguments));
auto app = TRY(GUI::Application::create(arguments));
TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_scheme("/usr/share/man/man6/GameOfLife.md") }));
TRY(Desktop::Launcher::seal_allowlist());

View file

@ -29,7 +29,7 @@
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
auto app = TRY(GUI::Application::try_create(arguments));
auto app = TRY(GUI::Application::create(arguments));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-hearts"sv));
Config::pledge_domains({ "Games", "Hearts" });

View file

@ -25,7 +25,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath recvfd sendfd unix"));
auto app = TRY(GUI::Application::try_create(arguments));
auto app = TRY(GUI::Application::create(arguments));
Config::pledge_domain("MasterWord");

View file

@ -29,7 +29,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath recvfd sendfd unix"));
auto app = TRY(GUI::Application::try_create(arguments));
auto app = TRY(GUI::Application::create(arguments));
Config::pledge_domain("Minesweeper");

View file

@ -30,7 +30,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath recvfd sendfd unix"));
auto app = TRY(GUI::Application::try_create(arguments));
auto app = TRY(GUI::Application::create(arguments));
Config::pledge_domain("Snake");
Config::monitor_domain("Snake");

View file

@ -29,7 +29,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio recvfd sendfd rpath unix proc exec"));
auto app = TRY(GUI::Application::try_create(arguments));
auto app = TRY(GUI::Application::create(arguments));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-solitaire"sv));
auto const man_file = "/usr/share/man/man6/Solitaire.md"sv;

View file

@ -42,7 +42,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio recvfd sendfd rpath unix proc exec"));
auto app = TRY(GUI::Application::try_create(arguments));
auto app = TRY(GUI::Application::create(arguments));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-spider"sv));
Config::pledge_domains({ "Games", "Spider" });