summaryrefslogtreecommitdiff
path: root/gladeui/glade-widget.c
diff options
context:
space:
mode:
authorJuan Pablo Ugarte <juanpablougarte@gmail.com>2013-11-15 22:45:17 -0300
committerJuan Pablo Ugarte <juanpablougarte@gmail.com>2013-11-15 23:44:47 -0300
commit2bc40ad87be072aac2759755df63707d43f8415c (patch)
treed2aef65c7f35a6fcfd1b7be4f77e29d7d785bb77 /gladeui/glade-widget.c
parentaf72b2dad1f4fa153a7449312841eec4d0a1e1dc (diff)
downloadglade-2bc40ad87be072aac2759755df63707d43f8415c.tar.gz
Sort object dependancy before saving using a topological
sorting algorithm _glade_tsort() instead of g_list_sort() with glade_widget_depends() which is not a transitive property. Closes Bug 709609 "[PATCH] Change way of sorting before writing XML output." Fixes Bug 711858 "editing glade project results in long CPU usage spikes after upgrading to 3.16 and GTK+3.10"
Diffstat (limited to 'gladeui/glade-widget.c')
-rw-r--r--gladeui/glade-widget.c66
1 files changed, 23 insertions, 43 deletions
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index 2ea24573..df3a965f 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -44,7 +44,7 @@
#include "glade-accumulators.h"
#include "glade-project.h"
#include "glade-widget-adaptor.h"
-#include "glade-widget.h"
+#include "glade-widget-private.h"
#include "glade-marshallers.h"
#include "glade-property.h"
#include "glade-property-class.h"
@@ -148,7 +148,9 @@ struct _GladeWidgetPrivate {
*/
GtkTreeModel *signal_model; /* Signal model (or NULL if not yet requested) */
-
+
+ GladeWidget *cached_toplevel; /* Used to speed up glade_widget_get_toplevel */
+
/* Construct parameters: */
GladeWidget *construct_template;
GladeCreateReason construct_reason;
@@ -2045,6 +2047,14 @@ glade_widget_create_packing_properties (GladeWidget * container,
return g_list_reverse (packing_props);
}
+/* Private API */
+
+GList *
+_glade_widget_peek_prop_refs (GladeWidget *widget)
+{
+ return widget->priv->prop_refs;
+}
+
/*******************************************************************************
API
*******************************************************************************/
@@ -3633,6 +3643,9 @@ glade_widget_set_parent (GladeWidget * widget, GladeWidget * parent)
old_parent = widget->priv->parent;
widget->priv->parent = parent;
+ /* unset toplevel cache used in glade_widget_get_toplevel() */
+ widget->priv->cached_toplevel = NULL;
+
/* Set packing props only if the object is actually parented by 'parent'
* (a subsequent call should come from glade_command after parenting).
*/
@@ -3744,9 +3757,14 @@ glade_widget_get_toplevel (GladeWidget * widget)
GladeWidget *toplevel = widget;
g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ if (widget->priv->cached_toplevel)
+ return widget->priv->cached_toplevel;
+
while (toplevel->priv->parent)
toplevel = toplevel->priv->parent;
+ widget->priv->cached_toplevel = toplevel;
+
return toplevel;
}
@@ -4343,11 +4361,8 @@ glade_widget_is_ancestor (GladeWidget * widget, GladeWidget * ancestor)
* Determines whether @widget is somehow dependent on @other, in
* which case it should be serialized after @other.
*
- * A widget is dependent on another widget if @widget or any
- * of @widget's children depends on @other or any of @other's children.
- *
- * <note><para>This is a very recursive operation, it is used once when
- * saving the project to ensure proper order at save time.</para></note>
+ * A widget is dependent on another widget.
+ * It does not take into account for children dependencies.
*
* Return value: %TRUE if @widget depends on @other.
**/
@@ -4358,42 +4373,7 @@ glade_widget_depends (GladeWidget *widget,
g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
g_return_val_if_fail (GLADE_IS_WIDGET (other), FALSE);
- if (!glade_widget_adaptor_depends (widget->priv->adaptor, widget, other))
- {
- gboolean depends;
- GList *children, *l;
-
- /* Recurse into 'other' */
- children = glade_widget_get_children (other);
- for (depends = FALSE, l = children;
- depends == FALSE && l != NULL;
- l = l->next)
- {
- GladeWidget *child = glade_widget_get_from_gobject (l->data);
-
- depends = glade_widget_depends (widget, child);
- }
-
- g_list_free (children);
- if (depends)
- return TRUE;
-
- /* Recurse into 'widget' */
- children = glade_widget_get_children (widget);
- for (depends = FALSE, l = children;
- depends == FALSE && l != NULL;
- l = l->next)
- {
- GladeWidget *child = glade_widget_get_from_gobject (l->data);
-
- depends = glade_widget_depends (child, other);
- }
- g_list_free (children);
-
- return depends;
- }
-
- return TRUE;
+ return glade_widget_adaptor_depends (widget->priv->adaptor, widget, other);
}
/**