mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-04-03 07:15:42 -04:00
connection: allow NULL implementation and listener in wl_closure_invoke
In practice, not all callbacks defined by a wl_interface are needed by every client or server. For instance, a client may only care about a subset of events on an object and leave the rest unhandled. Previously, a NULL implementation or a NULL listener function for a specific opcode would cause a fatal wl_abort(), forcing users to provide stub callbacks for every opcode even when they had nothing to do. This made code unnecessarily verbose. Downgrade the abort to a wl_log() warning and return early after cleaning up file descriptors. This allows partial interface implementations, simplifying user code while still logging a diagnostic message for debugging. Signed-off-by: Jie Liu <liujie01@kylinos.cn>
This commit is contained in:
parent
e647f6304d
commit
a4f861a49a
1 changed files with 5 additions and 2 deletions
|
|
@ -1232,13 +1232,16 @@ wl_closure_invoke(struct wl_closure *closure, uint32_t flags,
|
|||
|
||||
implementation = target->implementation;
|
||||
if (!implementation) {
|
||||
wl_abort("Implementation of resource %d of %s is NULL\n",
|
||||
wl_log("Implementation of resource %d of %s is NULL\n",
|
||||
target->id, target->interface->name);
|
||||
|
||||
return wl_closure_clear_fds(closure);
|
||||
}
|
||||
|
||||
if (!implementation[opcode]) {
|
||||
wl_abort("listener function for opcode %u of %s is NULL\n",
|
||||
wl_log("listener function for opcode %u of %s is NULL\n",
|
||||
opcode, target->interface->name);
|
||||
return wl_closure_clear_fds(closure);
|
||||
}
|
||||
ffi_call(&cif, implementation[opcode], NULL, ffi_args);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue