From dfca0def63671b51b4770b8f68b161db235920d9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 24 Nov 2021 00:09:41 +0100 Subject: [PATCH] Profiler: Port to LibMain :^) --- Userland/DevTools/Profiler/CMakeLists.txt | 2 +- Userland/DevTools/Profiler/main.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Userland/DevTools/Profiler/CMakeLists.txt b/Userland/DevTools/Profiler/CMakeLists.txt index c9b29e4602..d40ca81379 100644 --- a/Userland/DevTools/Profiler/CMakeLists.txt +++ b/Userland/DevTools/Profiler/CMakeLists.txt @@ -21,4 +21,4 @@ set(SOURCES ) serenity_app(Profiler ICON app-profiler) -target_link_libraries(Profiler LibGUI LibDesktop LibX86 LibSymbolication) +target_link_libraries(Profiler LibGUI LibDesktop LibX86 LibSymbolication LibMain) diff --git a/Userland/DevTools/Profiler/main.cpp b/Userland/DevTools/Profiler/main.cpp index ac3e4e2991..162ce7d536 100644 --- a/Userland/DevTools/Profiler/main.cpp +++ b/Userland/DevTools/Profiler/main.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include #include #include @@ -40,21 +42,21 @@ using namespace Profiler; static bool generate_profile(pid_t& pid); -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { int pid = 0; const char* perfcore_file_arg = nullptr; Core::ArgsParser args_parser; args_parser.add_option(pid, "PID to profile", "pid", 'p', "PID"); args_parser.add_positional_argument(perfcore_file_arg, "Path of perfcore file", "perfcore-file", Core::ArgsParser::Required::No); - args_parser.parse(argc, argv); + args_parser.parse(arguments); if (pid && perfcore_file_arg) { warnln("-p/--pid option and perfcore-file argument must not be used together!"); return 1; } - auto app = GUI::Application::construct(argc, argv); + auto app = TRY(GUI::Application::try_create(arguments)); auto app_icon = GUI::Icon::default_icon("app-profiler"); String perfcore_file; @@ -74,7 +76,7 @@ int main(int argc, char** argv) auto& profile = profile_or_error.value(); - auto window = GUI::Window::construct(); + auto window = TRY(GUI::Window::try_create()); if (!Desktop::Launcher::add_allowed_handler_with_only_specific_urls( "/bin/Help", @@ -92,12 +94,12 @@ int main(int argc, char** argv) main_widget.set_fill_with_background_color(true); main_widget.set_layout(); - auto timeline_header_container = GUI::Widget::construct(); + auto timeline_header_container = TRY(GUI::Widget::try_create()); timeline_header_container->set_layout(); timeline_header_container->set_fill_with_background_color(true); timeline_header_container->set_shrink_to_fit(true); - auto timeline_view = TimelineView::construct(*profile); + auto timeline_view = TRY(TimelineView::try_create(*profile)); for (auto& process : profile->processes()) { bool matching_event_found = false; for (auto& event : profile->events()) {