[gtk+] cssprovider: Have a section when parsing style properties
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] cssprovider: Have a section when parsing style properties
- Date: Wed, 28 Oct 2015 18:39:12 +0000 (UTC)
commit a58d8bdcbc291818ce70cf3e3fcb93e762ca9c36
Author: Benjamin Otte <otte redhat com>
Date: Wed Oct 28 19:35:23 2015 +0100
cssprovider: Have a section when parsing style properties
Signal handlers expect a section to be present, so provide them with
one.
New testcase included.
https://bugzilla.gnome.org/show_bug.cgi?id=757240
gtk/gtkcssprovider.c | 4 +++
testsuite/gtk/Makefile.am | 1 +
testsuite/gtk/cssprovider.c | 63 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 18a2c9c..50108c3 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1740,7 +1740,11 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
val->section,
val->section != NULL ? gtk_css_section_get_file
(val->section) : NULL,
val->value);
+ if (!val->section)
+ gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_VALUE);
found = _gtk_css_style_funcs_parse_value (value, scanner->parser);
+ if (!val->section)
+ gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_VALUE);
gtk_css_scanner_destroy (scanner);
break;
}
diff --git a/testsuite/gtk/Makefile.am b/testsuite/gtk/Makefile.am
index 9a3809e..517492a 100644
--- a/testsuite/gtk/Makefile.am
+++ b/testsuite/gtk/Makefile.am
@@ -41,6 +41,7 @@ TEST_PROGS += \
cellarea \
check-icon-names \
clipboard \
+ cssprovider \
defaultvalue \
entry \
expander \
diff --git a/testsuite/gtk/cssprovider.c b/testsuite/gtk/cssprovider.c
new file mode 100644
index 0000000..5222620
--- /dev/null
+++ b/testsuite/gtk/cssprovider.c
@@ -0,0 +1,63 @@
+#include <gtk/gtk.h>
+
+static void
+assert_section_is_not_null (GtkCssProvider *provider,
+ GtkCssSection *section,
+ const GError *error,
+ gpointer unused)
+{
+ g_assert (section != NULL);
+}
+
+static void
+test_section_in_load_from_data (void)
+{
+ GtkCssProvider *provider;
+
+ provider = gtk_css_provider_new ();
+ g_signal_connect (provider, "parsing-error",
+ G_CALLBACK (assert_section_is_not_null), NULL);
+ gtk_css_provider_load_from_data (provider, "random garbage goes here", -1, NULL);
+ g_object_unref (provider);
+}
+
+static void
+test_section_in_style_property (void)
+{
+ GtkCssProvider *provider;
+ GtkWidgetClass *widget_class;
+ GtkWidgetPath *path;
+ GParamSpec *pspec;
+ GValue value = G_VALUE_INIT;
+
+ provider = gtk_css_provider_new ();
+ g_signal_connect (provider, "parsing-error",
+ G_CALLBACK (assert_section_is_not_null), NULL);
+ gtk_css_provider_load_from_data (provider, "* { -GtkWidget-interior-focus: random garbage goes here; }",
-1, NULL);
+
+ widget_class = g_type_class_ref (GTK_TYPE_WIDGET);
+ pspec = gtk_widget_class_find_style_property (widget_class, "interior-focus");
+ g_assert (pspec);
+ path = gtk_widget_path_new ();
+ gtk_widget_path_append_type (path, GTK_TYPE_WIDGET);
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ gtk_style_provider_get_style_property (GTK_STYLE_PROVIDER (provider), path, 0, pspec, &value);
+G_GNUC_END_IGNORE_DEPRECATIONS;
+
+ gtk_widget_path_unref (path);
+ g_type_class_unref (widget_class);
+ g_object_unref (provider);
+}
+
+int
+main (int argc, char *argv[])
+{
+ gtk_init (NULL, NULL);
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/cssprovider/section-in-load-from-data", test_section_in_load_from_data);
+ g_test_add_func ("/cssprovider/section-in-style-property", test_section_in_style_property);
+
+ return g_test_run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]