mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-03-24 09:06:21 -04:00
Unify error events
Consolidate the different error events into one. This event will also be usable for other interaces.
This commit is contained in:
parent
2d27f3b6e9
commit
1db0525572
5 changed files with 57 additions and 57 deletions
|
|
@ -28,21 +28,18 @@
|
||||||
<arg name="key" type="uint"/>
|
<arg name="key" type="uint"/>
|
||||||
</request>
|
</request>
|
||||||
|
|
||||||
<!-- A request addressed a non-existent object id. This is
|
<!-- A fatal error has occurred. -->
|
||||||
tyipcally a fatal error. -->
|
<event name="error">
|
||||||
<event name="invalid_object">
|
<arg name="object_id" type="object" interface="wl_object"/>
|
||||||
<arg name="object_id" type="uint"/>
|
<arg name="code" type="uint"/>
|
||||||
|
<arg name="message" type="string"/>
|
||||||
</event>
|
</event>
|
||||||
|
|
||||||
<!-- A request tried to invoke an opcode out of range. This is
|
<enum name="error">
|
||||||
typically a fatal error. -->
|
<entry name="invalid_object" value="0"/>
|
||||||
<event name="invalid_method">
|
<entry name="invalid_method" value="1"/>
|
||||||
<arg name="object_id" type="uint"/>
|
<entry name="no_memory" value="2"/>
|
||||||
<arg name="opcode" type="uint"/>
|
</enum>
|
||||||
</event>
|
|
||||||
|
|
||||||
<!-- A request has failed due to an out of memory error. -->
|
|
||||||
<event name="no_memory"/>
|
|
||||||
|
|
||||||
<!-- Notify the client of global objects. These are objects that
|
<!-- Notify the client of global objects. These are objects that
|
||||||
are created by the server. Globals are published on the
|
are created by the server. Globals are published on the
|
||||||
|
|
@ -88,7 +85,6 @@
|
||||||
</request>
|
</request>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
|
|
||||||
<!-- Shared memory support -->
|
<!-- Shared memory support -->
|
||||||
<interface name="wl_shm" version="1">
|
<interface name="wl_shm" version="1">
|
||||||
<!-- Transfer a shm buffer to the server. The allocated buffer
|
<!-- Transfer a shm buffer to the server. The allocated buffer
|
||||||
|
|
|
||||||
|
|
@ -258,27 +258,12 @@ wl_display_get_global(struct wl_display *display,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
display_handle_invalid_object(void *data,
|
display_handle_error(void *data,
|
||||||
struct wl_display *display, uint32_t id)
|
struct wl_display *display, struct wl_object *object,
|
||||||
|
uint32_t code, const char *message)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "sent request to invalid object\n");
|
fprintf(stderr, "%s@%d: error %d: %s\n",
|
||||||
abort();
|
object->interface->name, object->id, code, message);
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
display_handle_invalid_method(void *data,
|
|
||||||
struct wl_display *display,
|
|
||||||
uint32_t id, uint32_t opcode)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "sent invalid request opcode\n");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
display_handle_no_memory(void *data,
|
|
||||||
struct wl_display *display)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "server out of memory\n");
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -345,9 +330,7 @@ display_handle_key(void *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_display_listener display_listener = {
|
static const struct wl_display_listener display_listener = {
|
||||||
display_handle_invalid_object,
|
display_handle_error,
|
||||||
display_handle_invalid_method,
|
|
||||||
display_handle_no_memory,
|
|
||||||
display_handle_global,
|
display_handle_global,
|
||||||
display_handle_range,
|
display_handle_range,
|
||||||
display_handle_key
|
display_handle_key
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,21 @@ wl_client_post_event(struct wl_client *client, struct wl_object *sender,
|
||||||
wl_closure_destroy(closure);
|
wl_closure_destroy(closure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WL_EXPORT void
|
||||||
|
wl_client_post_error(struct wl_client *client, struct wl_object *object,
|
||||||
|
uint32_t code, const char *msg, ...)
|
||||||
|
{
|
||||||
|
char buffer[128];
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, msg);
|
||||||
|
vsnprintf(buffer, sizeof buffer, msg, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
wl_client_post_event(client, &client->display->object,
|
||||||
|
WL_DISPLAY_ERROR, object, code, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
wl_client_connection_data(int fd, uint32_t mask, void *data)
|
wl_client_connection_data(int fd, uint32_t mask, void *data)
|
||||||
{
|
{
|
||||||
|
|
@ -145,16 +160,20 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
||||||
|
|
||||||
object = wl_hash_table_lookup(client->display->objects, p[0]);
|
object = wl_hash_table_lookup(client->display->objects, p[0]);
|
||||||
if (object == NULL) {
|
if (object == NULL) {
|
||||||
wl_client_post_event(client, &client->display->object,
|
wl_client_post_error(client, &client->display->object,
|
||||||
WL_DISPLAY_INVALID_OBJECT, p[0]);
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||||||
|
"invalid object %d", p[0]);
|
||||||
wl_connection_consume(connection, size);
|
wl_connection_consume(connection, size);
|
||||||
len -= size;
|
len -= size;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opcode >= object->interface->method_count) {
|
if (opcode >= object->interface->method_count) {
|
||||||
wl_client_post_event(client, &client->display->object,
|
wl_client_post_error(client, &client->display->object,
|
||||||
WL_DISPLAY_INVALID_METHOD, p[0], opcode);
|
WL_DISPLAY_ERROR_INVALID_METHOD,
|
||||||
|
"invalid method %d, object %s@%d",
|
||||||
|
object->interface->name,
|
||||||
|
object->id, opcode);
|
||||||
wl_connection_consume(connection, size);
|
wl_connection_consume(connection, size);
|
||||||
len -= size;
|
len -= size;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -167,9 +186,11 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
||||||
len -= size;
|
len -= size;
|
||||||
|
|
||||||
if (closure == NULL && errno == EINVAL) {
|
if (closure == NULL && errno == EINVAL) {
|
||||||
wl_client_post_event(client, &client->display->object,
|
wl_client_post_error(client, &client->display->object,
|
||||||
WL_DISPLAY_INVALID_METHOD,
|
WL_DISPLAY_ERROR_INVALID_METHOD,
|
||||||
p[0], opcode);
|
"invalid arguments for %s@%d.%s",
|
||||||
|
object->interface->name,
|
||||||
|
object->id, message->name);
|
||||||
continue;
|
continue;
|
||||||
} else if (closure == NULL && errno == ENOMEM) {
|
} else if (closure == NULL && errno == ENOMEM) {
|
||||||
wl_client_post_no_memory(client);
|
wl_client_post_no_memory(client);
|
||||||
|
|
@ -270,9 +291,8 @@ wl_client_add_resource(struct wl_client *client,
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
wl_client_post_no_memory(struct wl_client *client)
|
wl_client_post_no_memory(struct wl_client *client)
|
||||||
{
|
{
|
||||||
wl_client_post_event(client,
|
wl_client_post_error(client, &client->display->object,
|
||||||
&client->display->object,
|
WL_DISPLAY_ERROR_NO_MEMORY, "no memory");
|
||||||
WL_DISPLAY_NO_MEMORY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,8 @@ int wl_display_add_global(struct wl_display *display,
|
||||||
|
|
||||||
struct wl_client *wl_client_create(struct wl_display *display, int fd);
|
struct wl_client *wl_client_create(struct wl_display *display, int fd);
|
||||||
void wl_client_destroy(struct wl_client *client);
|
void wl_client_destroy(struct wl_client *client);
|
||||||
|
void wl_client_post_error(struct wl_client *client, struct wl_object *object,
|
||||||
|
uint32_t code, const char *msg, ...);
|
||||||
void wl_client_post_no_memory(struct wl_client *client);
|
void wl_client_post_no_memory(struct wl_client *client);
|
||||||
void wl_client_post_global(struct wl_client *client, struct wl_object *object);
|
void wl_client_post_global(struct wl_client *client, struct wl_object *object);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,18 +124,17 @@ shm_create_buffer(struct wl_client *client, struct wl_shm *shm,
|
||||||
/* FIXME: Define a real exception event instead of abusing the
|
/* FIXME: Define a real exception event instead of abusing the
|
||||||
* display.invalid_object error */
|
* display.invalid_object error */
|
||||||
if (visual->object.interface != &wl_visual_interface) {
|
if (visual->object.interface != &wl_visual_interface) {
|
||||||
wl_client_post_event(client, (struct wl_object *) display,
|
wl_client_post_error(client, (struct wl_object *) display,
|
||||||
WL_DISPLAY_INVALID_OBJECT, 0);
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||||||
fprintf(stderr, "invalid visual in create_buffer\n");
|
"invalid visual in create_buffer\n");
|
||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width < 0 || height < 0 || stride < width) {
|
if (width < 0 || height < 0 || stride < width) {
|
||||||
wl_client_post_event(client, (struct wl_object *) display,
|
wl_client_post_error(client, (struct wl_object *) display,
|
||||||
WL_DISPLAY_INVALID_OBJECT, 0);
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||||||
fprintf(stderr,
|
"invalid width, height or stride in create_buffer\n");
|
||||||
"invalid width, height or stride in create_buffer\n");
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -147,9 +146,9 @@ shm_create_buffer(struct wl_client *client, struct wl_shm *shm,
|
||||||
if (data == MAP_FAILED) {
|
if (data == MAP_FAILED) {
|
||||||
/* FIXME: Define a real exception event instead of
|
/* FIXME: Define a real exception event instead of
|
||||||
* abusing this one */
|
* abusing this one */
|
||||||
wl_client_post_event(client, (struct wl_object *) display,
|
wl_client_post_error(client, (struct wl_object *) display,
|
||||||
WL_DISPLAY_INVALID_OBJECT, 0);
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||||||
fprintf(stderr, "failed to create image for fd %d\n", fd);
|
"failed to create image for fd %d\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue