Fix crash in container_descendants()
If root is a C_VIEW, the children property is a null pointer.
This commit is contained in:
parent
82cb379727
commit
22b9169631
|
@ -355,16 +355,17 @@ struct sway_container *container_view_create(struct sway_container *sibling,
|
||||||
void container_descendants(struct sway_container *root,
|
void container_descendants(struct sway_container *root,
|
||||||
enum sway_container_type type,
|
enum sway_container_type type,
|
||||||
void (*func)(struct sway_container *item, void *data), void *data) {
|
void (*func)(struct sway_container *item, void *data), void *data) {
|
||||||
|
if (!root->children || !root->children->length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (int i = 0; i < root->children->length; ++i) {
|
for (int i = 0; i < root->children->length; ++i) {
|
||||||
struct sway_container *item = root->children->items[i];
|
struct sway_container *item = root->children->items[i];
|
||||||
if (item->type == type) {
|
if (item->type == type) {
|
||||||
func(item, data);
|
func(item, data);
|
||||||
}
|
}
|
||||||
if (item->children && item->children->length) {
|
|
||||||
container_descendants(item, type, func, data);
|
container_descendants(item, type, func, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
struct sway_container *container_find(struct sway_container *container,
|
struct sway_container *container_find(struct sway_container *container,
|
||||||
bool (*test)(struct sway_container *view, void *data), void *data) {
|
bool (*test)(struct sway_container *view, void *data), void *data) {
|
||||||
|
|
Loading…
Reference in a new issue