diff --git a/Userland/DevTools/Playground/CMakeLists.txt b/Userland/DevTools/Playground/CMakeLists.txt index 8b8a2604eb..9490122ff3 100644 --- a/Userland/DevTools/Playground/CMakeLists.txt +++ b/Userland/DevTools/Playground/CMakeLists.txt @@ -9,4 +9,4 @@ set(SOURCES ) serenity_app(Playground ICON app-playground) -target_link_libraries(Playground LibDesktop LibGUI) +target_link_libraries(Playground LibDesktop LibGUI LibMain) diff --git a/Userland/DevTools/Playground/main.cpp b/Userland/DevTools/Playground/main.cpp index 78f51c7fa4..f35f5543c2 100644 --- a/Userland/DevTools/Playground/main.cpp +++ b/Userland/DevTools/Playground/main.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -24,6 +25,7 @@ #include #include #include +#include #include #include @@ -58,20 +60,12 @@ void UnregisteredWidget::paint_event(GUI::PaintEvent& event) } -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { - if (pledge("stdio thread recvfd sendfd cpath rpath wpath unix", nullptr) < 0) { - perror("pledge"); - return 1; - } - - auto app = GUI::Application::construct(argc, argv); - - if (pledge("stdio thread recvfd sendfd rpath cpath wpath unix", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio thread recvfd sendfd cpath rpath wpath unix", nullptr)); + auto app = TRY(GUI::Application::try_create(arguments)); + TRY(Core::System::pledge("stdio thread recvfd sendfd rpath cpath wpath unix", nullptr)); if (!Desktop::Launcher::add_allowed_handler_with_only_specific_urls( "/bin/Help", { URL::create_with_file_protocol("/usr/share/man/man1/Playground.md") }) @@ -80,18 +74,15 @@ int main(int argc, char** argv) return 1; } - if (pledge("stdio thread recvfd sendfd rpath cpath wpath", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio thread recvfd sendfd rpath cpath wpath", nullptr)); const char* path = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(path, "GML file to edit", "file", Core::ArgsParser::Required::No); - args_parser.parse(argc, argv); + args_parser.parse(arguments); auto app_icon = GUI::Icon::default_icon("app-playground"); - auto window = GUI::Window::construct(); + auto window = TRY(GUI::Window::try_create()); window->set_title("GML Playground"); window->set_icon(app_icon.bitmap_for_size(16)); window->resize(800, 600);