module/niri-workspaces: fix crash when monitor off

The niri-workspaces module would crash if niri's event stream produced
a `WorkspaceChanged` event containing a workspace with no output,
which can occur if the monitor is turned off.  Update the response
parser to handle this situation.
This commit is contained in:
Willem van de Krol 2025-03-25 19:23:54 +01:00
parent 43e1944607
commit 4eb054792e
No known key found for this signature in database
GPG key ID: 7D59BA3F0F7B0B2F

View file

@ -73,7 +73,7 @@ parser(char *response)
// only add workspaces on the current yambar's monitor // only add workspaces on the current yambar's monitor
struct json_object *output = json_object_object_get(ws_obj, "output"); struct json_object *output = json_object_object_get(ws_obj, "output");
if (strcmp(instance.monitor, json_object_get_string(output)) != 0) if (output == NULL || strcmp(instance.monitor, json_object_get_string(output)) != 0)
continue; continue;
struct niri_workspace *ws = calloc(1, sizeof(*ws)); struct niri_workspace *ws = calloc(1, sizeof(*ws));