From db79f1cb784eb064020b0a1a57b2bc021f345f75 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 23 Nov 2021 16:08:52 +0100 Subject: [PATCH] Welcome: Port to LibMain :^) --- Userland/Applications/Welcome/CMakeLists.txt | 2 +- Userland/Applications/Welcome/main.cpp | 44 +++++--------------- 2 files changed, 12 insertions(+), 34 deletions(-) diff --git a/Userland/Applications/Welcome/CMakeLists.txt b/Userland/Applications/Welcome/CMakeLists.txt index 2b3b8e940a..14172ed1d4 100644 --- a/Userland/Applications/Welcome/CMakeLists.txt +++ b/Userland/Applications/Welcome/CMakeLists.txt @@ -13,4 +13,4 @@ set(SOURCES ) serenity_app(Welcome ICON app-welcome) -target_link_libraries(Welcome LibGUI LibWeb) +target_link_libraries(Welcome LibGUI LibWeb LibMain) diff --git a/Userland/Applications/Welcome/main.cpp b/Userland/Applications/Welcome/main.cpp index 86419ff85c..c76c2a67e3 100644 --- a/Userland/Applications/Welcome/main.cpp +++ b/Userland/Applications/Welcome/main.cpp @@ -6,50 +6,28 @@ #include "WelcomeWidget.h" #include +#include #include #include #include +#include #include -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { - if (pledge("stdio recvfd sendfd rpath unix proc exec", nullptr) < 0) { - perror("pledge"); - return 1; - } - - auto app = GUI::Application::construct(argc, argv); + TRY(Core::System::pledge("stdio recvfd sendfd rpath unix proc exec", nullptr)); + auto app = TRY(GUI::Application::try_create(arguments)); Config::pledge_domains("SystemServer"); - if (unveil("/res", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/home", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/tmp/portal/webcontent", "rw") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/bin/Help", "x") < 0) { - perror("unveil"); - return 1; - } - - if (unveil(nullptr, nullptr) < 0) { - perror("unveil"); - return 1; - } - + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil("/home", "r")); + TRY(Core::System::unveil("/tmp/portal/webcontent", "rw")); + TRY(Core::System::unveil("/bin/Help", "x")); + TRY(Core::System::unveil(nullptr, nullptr)); auto app_icon = GUI::Icon::default_icon("app-welcome"); - auto window = GUI::Window::construct(); + auto window = TRY(GUI::Window::try_create()); window->resize(480, 250); window->center_on_screen();