serenity/Userland/Applications/Run/main.cpp
Bastiaan van der Plaat 582bf1eaf3 Run: Fix bug where it would crash because uninitialized main widget
The set_main_widget<T>() function only calls the construct and not
`try_create()` that the GMLCompiler generates so all calls to
`find_descendant_of_type_named()` would result in null
pointers that would resolve in a crash.
2024-02-06 08:41:01 +01:00

26 lines
715 B
C++

/*
* Copyright (c) 2021, Nick Vella <nick@nxk.io>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "RunWindow.h"
#include <LibCore/System.h>
#include <LibGUI/Application.h>
#include <LibGUI/Desktop.h>
#include <LibMain/Main.h>
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio recvfd sendfd thread cpath rpath wpath unix proc exec"));
auto app = TRY(GUI::Application::create(arguments));
auto window = TRY(Run::RunWindow::try_create());
constexpr int margin = 16;
window->move_to(margin, GUI::Desktop::the().rect().bottom() - 1 - GUI::Desktop::the().taskbar_height() - margin - window->height());
window->show();
return app->exec();
}