[gtk+/gtk-style-context: 476/533] Let gtk_widget_get_path() correct early calls during init().
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 476/533] Let gtk_widget_get_path() correct early calls during init().
- Date: Wed, 1 Dec 2010 02:45:50 +0000 (UTC)
commit 450a6eda582a93d4bc3b43b9505a8b089b1c82bd
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Nov 24 01:30:59 2010 +0100
Let gtk_widget_get_path() correct early calls during init().
gtk/gtkwidget.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 4262771..086994d 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -13802,6 +13802,18 @@ gtk_widget_get_path (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+ /* As strange as it may seem, this may happen on object construction.
+ * init() implementations of parent types may eventually call this function,
+ * each with its corresponding GType, which could leave a child
+ * implementation with a wrong widget type in the widget path
+ */
+ if (widget->priv->path &&
+ G_OBJECT_TYPE (widget) != gtk_widget_path_get_widget_type (widget->priv->path))
+ {
+ gtk_widget_path_free (widget->priv->path);
+ widget->priv->path = NULL;
+ }
+
if (!widget->priv->path)
{
GtkWidget *parent;
@@ -13825,6 +13837,10 @@ gtk_widget_get_path (GtkWidget *widget)
if (widget->priv->name)
gtk_widget_path_iter_set_name (widget->priv->path, pos, widget->priv->name);
+
+ if (widget->priv->context)
+ gtk_style_context_set_path (widget->priv->context,
+ widget->priv->path);
}
return widget->priv->path;
@@ -13869,6 +13885,13 @@ gtk_widget_get_style_context (GtkWidget *widget)
gtk_style_context_set_path (widget->priv->context,
widget->priv->path);
}
+ else
+ {
+ /* Force widget path regeneration if needed, the
+ * context will be updated within this function.
+ */
+ gtk_widget_get_path (widget);
+ }
return widget->priv->context;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]