Use the 'present' field to properly check that the XC-MISC

extension is available in xcb_generate_id.

Also document the returned value when xcb_generate_id fails.
This commit is contained in:
Eduardo Sánchez Muñoz 2020-03-02 18:59:45 +01:00
parent 4b40b44cb6
commit 704e0a91b1
2 changed files with 2 additions and 2 deletions

View File

@ -591,7 +591,7 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *display, xcb
/**
* @brief Allocates an XID for a new object.
* @param c The connection.
* @return A newly allocated XID.
* @return A newly allocated XID, or -1 on failure.
*
* Allocates an XID for a new object. Typically used just prior to
* various object creation functions, such as xcb_create_window.

View File

@ -55,7 +55,7 @@ uint32_t xcb_generate_id(xcb_connection_t *c)
/* check for extension */
const xcb_query_extension_reply_t *xc_misc_reply =
xcb_get_extension_data(c, &xcb_xc_misc_id);
if (!xc_misc_reply) {
if (!xc_misc_reply || !xc_misc_reply->present) {
pthread_mutex_unlock(&c->xid.lock);
return -1;
}