wind: Move more fallible operations before window creation
This commit is contained in:
parent
06f3affc71
commit
669e2747a7
@ -11,6 +11,7 @@
|
|||||||
auto _expr_rc = (expr); \
|
auto _expr_rc = (expr); \
|
||||||
if (!_expr_rc.has_value()) \
|
if (!_expr_rc.has_value()) \
|
||||||
{ \
|
{ \
|
||||||
|
g_windows.remove(window); \
|
||||||
delete window; \
|
delete window; \
|
||||||
os::IPC::send_error(client.conn, _expr_rc.error()); \
|
os::IPC::send_error(client.conn, _expr_rc.error()); \
|
||||||
return {}; \
|
return {}; \
|
||||||
@ -65,6 +66,8 @@ static Result<void> handle_create_window_message(Client& client)
|
|||||||
|
|
||||||
auto name = TRY(String::from_cstring("Window"));
|
auto name = TRY(String::from_cstring("Window"));
|
||||||
|
|
||||||
|
auto shm_path = TRY(String::format("/wind-shm-%d-%lu"_sv, client.conn.fd(), time(NULL)));
|
||||||
|
|
||||||
auto* window = new (std::nothrow) Window(request.rect, move(name), request.decorated);
|
auto* window = new (std::nothrow) Window(request.rect, move(name), request.decorated);
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
@ -72,8 +75,6 @@ static Result<void> handle_create_window_message(Client& client)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto shm_path = TRY_OR_IPC_ERROR(String::format("/wind-shm-%d-%lu"_sv, client.conn.fd(), time(NULL)));
|
|
||||||
|
|
||||||
window->pixels = (u32*)TRY_OR_IPC_ERROR(
|
window->pixels = (u32*)TRY_OR_IPC_ERROR(
|
||||||
os::SharedMemory::create(shm_path.view(), window->contents.height * window->contents.width * 4));
|
os::SharedMemory::create(shm_path.view(), window->contents.height * window->contents.width * 4));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user