wind: Show which IPC function was called with an invalid window id
This commit is contained in:
parent
7d69ac56e2
commit
5087b6db30
16
wind/IPC.cpp
16
wind/IPC.cpp
@ -19,11 +19,11 @@
|
||||
_expr_rc.release_value(); \
|
||||
})
|
||||
|
||||
#define CHECK_WINDOW_ID(request) \
|
||||
#define CHECK_WINDOW_ID(request, context) \
|
||||
do { \
|
||||
if ((usize)request.window >= client.windows.size() || !client.windows[request.window]) \
|
||||
{ \
|
||||
os::eprintln("wind: Window id is invalid!"); \
|
||||
os::eprintln("wind: Window id is invalid! (%s)", context); \
|
||||
return {}; \
|
||||
} \
|
||||
} while (0)
|
||||
@ -76,7 +76,7 @@ static Result<void> handle_remove_shm_message(Client& client)
|
||||
ui::RemoveSharedMemoryRequest request;
|
||||
if (!TRY(client.conn->read_message(request))) return {};
|
||||
|
||||
CHECK_WINDOW_ID(request);
|
||||
CHECK_WINDOW_ID(request, "RemoveShm");
|
||||
|
||||
shm_unlink(client.windows[request.window]->shm_path.chars());
|
||||
|
||||
@ -92,7 +92,7 @@ static Result<void> handle_set_window_title_message(Client& client)
|
||||
|
||||
os::println("wind: SetWindowTitle(\"%s\") for window %d", name.chars(), request.window);
|
||||
|
||||
CHECK_WINDOW_ID(request);
|
||||
CHECK_WINDOW_ID(request, "SetWindowTitle");
|
||||
|
||||
client.windows[request.window]->name = move(name);
|
||||
|
||||
@ -104,7 +104,7 @@ static Result<void> handle_invalidate_message(Client& client)
|
||||
ui::InvalidateRequest request;
|
||||
if (!TRY(client.conn->read_message(request))) return {};
|
||||
|
||||
CHECK_WINDOW_ID(request);
|
||||
CHECK_WINDOW_ID(request, "Invalidate");
|
||||
|
||||
client.windows[request.window]->dirty = true;
|
||||
|
||||
@ -116,7 +116,7 @@ static Result<void> handle_close_window_message(Client& client)
|
||||
ui::CloseWindowRequest request;
|
||||
if (!TRY(client.conn->read_message(request))) return {};
|
||||
|
||||
CHECK_WINDOW_ID(request);
|
||||
CHECK_WINDOW_ID(request, "CloseWindow");
|
||||
|
||||
auto* window = client.windows[request.window];
|
||||
client.windows[request.window] = nullptr;
|
||||
@ -146,7 +146,7 @@ static Result<void> handle_set_titlebar_height_message(Client& client)
|
||||
|
||||
if (request.height < 0) request.height = 0;
|
||||
|
||||
CHECK_WINDOW_ID(request);
|
||||
CHECK_WINDOW_ID(request, "SetTitlebarHeight");
|
||||
|
||||
auto* window = client.windows[request.window];
|
||||
|
||||
@ -173,7 +173,7 @@ static Result<void> handle_set_special_window_attributes_message(Client& client)
|
||||
return {};
|
||||
}
|
||||
|
||||
CHECK_WINDOW_ID(request);
|
||||
CHECK_WINDOW_ID(request, "SetSpecialWindowAttributes");
|
||||
|
||||
client.windows[request.window]->attributes = request.attributes;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user