[gtk/wip/ebassi/constraint-layout: 43/69] Detach guides on unroot
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/ebassi/constraint-layout: 43/69] Detach guides on unroot
- Date: Sun, 30 Jun 2019 23:13:44 +0000 (UTC)
commit 61b4febbafe4673195b8cd092ed33905fed4c225
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jun 27 18:49:54 2019 +0000
Detach guides on unroot
We don't want to leave constraints behind.
gtk/gtkconstraintlayout.c | 35 +++++++++++++++++++++++++++++++----
1 file changed, 31 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkconstraintlayout.c b/gtk/gtkconstraintlayout.c
index 9e1cff0049..fb26f422ef 100644
--- a/gtk/gtkconstraintlayout.c
+++ b/gtk/gtkconstraintlayout.c
@@ -1065,6 +1065,7 @@ gtk_constraint_layout_allocate (GtkLayoutManager *manager,
static void gtk_constraint_guide_update (GtkConstraintGuide *guide,
GuideValue index);
+static void gtk_constraint_guide_detach (GtkConstraintGuide *guide);
static void
gtk_constraint_layout_root (GtkLayoutManager *manager)
@@ -1117,6 +1118,13 @@ gtk_constraint_layout_unroot (GtkLayoutManager *manager)
gtk_constraint_detach (constraint);
}
+ g_hash_table_iter_init (&iter, self->guides);
+ while (g_hash_table_iter_next (&iter, &key, NULL))
+ {
+ GtkConstraintGuide *guide = key;
+ gtk_constraint_guide_detach (guide);
+ }
+
self->solver = NULL;
}
@@ -1327,6 +1335,28 @@ gtk_constraint_guide_update (GtkConstraintGuide *guide,
weight[index]);
}
+static void
+gtk_constraint_guide_detach (GtkConstraintGuide *guide)
+{
+ GtkConstraintSolver *solver;
+ int i;
+
+ if (!guide->layout)
+ return;
+
+ solver = guide->layout->solver;
+ if (!solver)
+ return;
+
+ for (i = 0; i < LAST_GUIDE_VALUE; i++)
+ {
+ gtk_constraint_solver_remove_constraint (solver, guide->constraints[i]);
+ guide->constraints[i] = NULL;
+ }
+
+ g_hash_table_remove_all (guide->data.bound_attributes);
+}
+
static void
gtk_constraint_guide_set_property (GObject *gobject,
guint prop_id,
@@ -1477,14 +1507,11 @@ void
gtk_constraint_layout_remove_guide (GtkConstraintLayout *layout,
GtkConstraintGuide *guide)
{
- GtkConstraintSolver *solver;
-
g_return_if_fail (GTK_IS_CONSTRAINT_LAYOUT (layout));
g_return_if_fail (GTK_IS_CONSTRAINT_GUIDE (guide));
g_return_if_fail (guide->layout == layout);
- solver = gtk_constraint_layout_get_solver (guide->layout);
- clear_constraint_solver_data (solver, &guide->data);
+ gtk_constraint_guide_detach (guide);
guide->layout = NULL;
g_hash_table_remove (layout->guides, guide);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]