diff options
author | Björn Esser <besser82@fedoraproject.org> | 2017-12-14 01:30:54 +0100 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2017-12-17 15:53:22 -0500 |
commit | c08c805ecd8f2000a35cdeae7b16244d0b3c0528 (patch) | |
tree | 8a1a12a32a1d2c40bc4fdb43aa7205362438f65b /swaygrab/json.c | |
parent | Revert "Merge remote-tracking branch 'besser82/bugfix/json-c' into 0.15" (diff) | |
download | sway-935f1ac2bb5eede42fc61f17363697ec0b0b5bc9.tar.gz sway-935f1ac2bb5eede42fc61f17363697ec0b0b5bc9.tar.zst sway-935f1ac2bb5eede42fc61f17363697ec0b0b5bc9.zip |
Adaptions for API change in json-c v0.130.15.1
Lift restriction on json-c <= 0.12.1
ipc-server: Acquire ownership of referenced json_object properly
When adding a referenced json_object with an unknown lifetime to
another json_object, it must be done with a wrapped call to
json_object_get() to acquire the ownership of that json_object.
Diffstat (limited to 'swaygrab/json.c')
-rw-r--r-- | swaygrab/json.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/swaygrab/json.c b/swaygrab/json.c index 286085c3..f0e8fa90 100644 --- a/swaygrab/json.c +++ b/swaygrab/json.c | |||
@@ -50,8 +50,7 @@ static json_object *get_focused_container_r(json_object *c) { | |||
50 | } else { | 50 | } else { |
51 | json_object *nodes, *node, *child; | 51 | json_object *nodes, *node, *child; |
52 | json_object_object_get_ex(c, "nodes", &nodes); | 52 | json_object_object_get_ex(c, "nodes", &nodes); |
53 | int i; | 53 | for (json_ar_len_t i = 0; i < json_object_array_length(nodes); i++) { |
54 | for (i = 0; i < json_object_array_length(nodes); i++) { | ||
55 | node = json_object_array_get_idx(nodes, i); | 54 | node = json_object_array_get_idx(nodes, i); |
56 | 55 | ||
57 | if ((child = get_focused_container_r(node))) { | 56 | if ((child = get_focused_container_r(node))) { |
@@ -60,7 +59,7 @@ static json_object *get_focused_container_r(json_object *c) { | |||
60 | } | 59 | } |
61 | 60 | ||
62 | json_object_object_get_ex(c, "floating_nodes", &nodes); | 61 | json_object_object_get_ex(c, "floating_nodes", &nodes); |
63 | for (i = 0; i < json_object_array_length(nodes); i++) { | 62 | for (json_ar_len_t i = 0; i < json_object_array_length(nodes); i++) { |
64 | node = json_object_array_get_idx(nodes, i); | 63 | node = json_object_array_get_idx(nodes, i); |
65 | 64 | ||
66 | if ((child = get_focused_container_r(node))) { | 65 | if ((child = get_focused_container_r(node))) { |
@@ -83,7 +82,7 @@ char *get_focused_output() { | |||
83 | if (!outputs) { | 82 | if (!outputs) { |
84 | sway_abort("Unabled to get focused output. No nodes in tree."); | 83 | sway_abort("Unabled to get focused output. No nodes in tree."); |
85 | } | 84 | } |
86 | for (int i = 0; i < json_object_array_length(outputs); i++) { | 85 | for (json_ar_len_t i = 0; i < json_object_array_length(outputs); i++) { |
87 | output = json_object_array_get_idx(outputs, i); | 86 | output = json_object_array_get_idx(outputs, i); |
88 | 87 | ||
89 | if (get_focused_container_r(output)) { | 88 | if (get_focused_container_r(output)) { |
@@ -131,7 +130,7 @@ json_object *get_output_container(const char *output) { | |||
131 | json_object *outputs, *json_output, *name; | 130 | json_object *outputs, *json_output, *name; |
132 | json_object_object_get_ex(tree, "nodes", &outputs); | 131 | json_object_object_get_ex(tree, "nodes", &outputs); |
133 | 132 | ||
134 | for (int i = 0; i < json_object_array_length(outputs); i++) { | 133 | for (json_ar_len_t i = 0; i < json_object_array_length(outputs); i++) { |
135 | json_output = json_object_array_get_idx(outputs, i); | 134 | json_output = json_object_array_get_idx(outputs, i); |
136 | json_object_object_get_ex(json_output, "name", &name); | 135 | json_object_object_get_ex(json_output, "name", &name); |
137 | 136 | ||