summaryrefslogtreecommitdiff
path: root/gtk/gtkcssstaticstyle.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2015-11-20 19:37:52 +0100
committerBenjamin Otte <otte@redhat.com>2015-11-20 21:22:15 +0100
commitd75989a52b6e19aa53de3c8d08ae47c6441882ed (patch)
tree2f08c17452d6667909036a6fa66fb5dca51ffb60 /gtk/gtkcssstaticstyle.c
parent6489ec440fde74a4db3ed283b1e96f94120e45af (diff)
downloadgtk+-d75989a52b6e19aa53de3c8d08ae47c6441882ed.tar.gz
cssstyle: Don't store custom css properties
This makes custom CSS properties no longer configurable. But it avoids crashes when loading custom themes, so that's a good thing. Testcase included. https://bugzilla.redhat.com/show_bug.cgi?id=1281234
Diffstat (limited to 'gtk/gtkcssstaticstyle.c')
-rw-r--r--gtk/gtkcssstaticstyle.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c
index 34563e0157..fa60414370 100644
--- a/gtk/gtkcssstaticstyle.c
+++ b/gtk/gtkcssstaticstyle.c
@@ -46,11 +46,14 @@ gtk_css_static_style_get_value (GtkCssStyle *style,
{
GtkCssStaticStyle *sstyle = GTK_CSS_STATIC_STYLE (style);
- if (sstyle->values == NULL ||
- id >= sstyle->values->len)
- return NULL;
+ if (G_UNLIKELY (id >= GTK_CSS_PROPERTY_N_PROPERTIES))
+ {
+ GtkCssStyleProperty *prop = _gtk_css_style_property_lookup_by_id (id);
- return g_ptr_array_index (sstyle->values, id);
+ return _gtk_css_style_property_get_initial_value (prop);
+ }
+
+ return sstyle->values[id];
}
static GtkCssSection *
@@ -70,11 +73,12 @@ static void
gtk_css_static_style_dispose (GObject *object)
{
GtkCssStaticStyle *style = GTK_CSS_STATIC_STYLE (object);
+ guint i;
- if (style->values)
+ for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
{
- g_ptr_array_unref (style->values);
- style->values = NULL;
+ if (style->values[i])
+ _gtk_css_value_unref (style->values[i]);
}
if (style->sections)
{
@@ -115,14 +119,9 @@ gtk_css_static_style_set_value (GtkCssStaticStyle *style,
GtkCssValue *value,
GtkCssSection *section)
{
- if (style->values == NULL)
- style->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
- if (id >= style->values->len)
- g_ptr_array_set_size (style->values, id + 1);
-
- if (g_ptr_array_index (style->values, id))
- _gtk_css_value_unref (g_ptr_array_index (style->values, id));
- g_ptr_array_index (style->values, id) = _gtk_css_value_ref (value);
+ if (style->values[id])
+ _gtk_css_value_unref (style->values[id]);
+ style->values[id] = _gtk_css_value_ref (value);
if (style->sections && style->sections->len > id && g_ptr_array_index (style->sections, id))
{
@@ -208,6 +207,7 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
gtk_internal_return_if_fail (GTK_IS_CSS_STATIC_STYLE (style));
gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider));
gtk_internal_return_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style));
+ gtk_internal_return_if_fail (id < GTK_CSS_PROPERTY_N_PROPERTIES);
/* http://www.w3.org/TR/css3-cascade/#cascade
* Then, for every element, the value for each property can be found