css node: Warn more

gtk_css_node_insert_before/after can easily create cycles
which later lead to stack overflows. Even if we're not
catching all cycles here, at least we can detect obviously
invalid arguments, such as inserting a node next to itself.
This commit is contained in:
Matthias Clasen 2015-12-08 16:51:21 -05:00
parent e2bc77b9af
commit f2dd4350b2

View File

@ -873,6 +873,7 @@ gtk_css_node_insert_after (GtkCssNode *parent,
GtkCssNode *previous_sibling)
{
g_return_if_fail (previous_sibling == NULL || previous_sibling->parent == parent);
g_return_if_fail (cssnode != previous_sibling);
if (cssnode->previous_sibling == previous_sibling &&
cssnode->parent == parent)
@ -890,6 +891,7 @@ gtk_css_node_insert_before (GtkCssNode *parent,
GtkCssNode *next_sibling)
{
g_return_if_fail (next_sibling == NULL || next_sibling->parent == parent);
g_return_if_fail (cssnode != next_sibling);
if (cssnode->next_sibling == next_sibling &&
cssnode->parent == parent)