1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:07:36 +00:00

GameOfLife: Port to LibMain

Simplified two pledge() and two unveil() by using TRY().
This commit is contained in:
Pedro Pereira 2021-11-23 10:37:19 +00:00 committed by Andreas Kling
parent 8d3059c6f5
commit 3ca2f192af
2 changed files with 9 additions and 21 deletions

View file

@ -15,4 +15,4 @@ set(SOURCES
) )
serenity_app(GameOfLife ICON app-gameoflife) serenity_app(GameOfLife ICON app-gameoflife)
target_link_libraries(GameOfLife LibGUI) target_link_libraries(GameOfLife LibGUI LibMain)

View file

@ -7,6 +7,7 @@
#include "BoardWidget.h" #include "BoardWidget.h"
#include <Games/GameOfLife/GameOfLifeGML.h> #include <Games/GameOfLife/GameOfLifeGML.h>
#include <LibCore/System.h>
#include <LibGUI/Application.h> #include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h> #include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h> #include <LibGUI/Button.h>
@ -18,33 +19,20 @@
#include <LibGUI/Toolbar.h> #include <LibGUI/Toolbar.h>
#include <LibGUI/ToolbarContainer.h> #include <LibGUI/ToolbarContainer.h>
#include <LibGUI/Window.h> #include <LibGUI/Window.h>
#include <unistd.h> #include <LibMain/Main.h>
const char* click_tip = "Tip: click the board to toggle individual cells, or click+drag to toggle multiple cells"; const char* click_tip = "Tip: click the board to toggle individual cells, or click+drag to toggle multiple cells";
int main(int argc, char** argv) ErrorOr<int> serenity_main(Main::Arguments arguments)
{ {
if (pledge("stdio rpath recvfd sendfd unix", nullptr) < 0) { TRY(Core::System::pledge("stdio rpath recvfd sendfd unix", nullptr));
perror("pledge");
return 1;
}
auto app = GUI::Application::construct(argc, argv); auto app = GUI::Application::construct(arguments);
if (pledge("stdio rpath recvfd sendfd", nullptr) < 0) { TRY(Core::System::pledge("stdio rpath recvfd sendfd", nullptr));
perror("pledge");
return 1;
}
if (unveil("/res", "r") < 0) { TRY(Core::System::unveil("/res", "r"));
perror("unveil"); TRY(Core::System::unveil(nullptr, nullptr));
return 1;
}
if (unveil(nullptr, nullptr) < 0) {
perror("unveil");
return 1;
}
auto app_icon = GUI::Icon::default_icon("app-gameoflife"); auto app_icon = GUI::Icon::default_icon("app-gameoflife");