[balsa/popover: 1/65] balsa-index: Clear an idle handler at dispose time




commit 90a305979a042b2106e4af858d8801c296bc78c1
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sun Aug 30 15:28:05 2020 -0400

    balsa-index: Clear an idle handler at dispose time
    
    instead holding a reference on the BalsaIndex.

 src/balsa-index.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/balsa-index.c b/src/balsa-index.c
index bf435ef9d..554149df5 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -175,6 +175,7 @@ struct _BalsaIndex {
     guint selection_changed_idle_id;
     guint mailbox_changed_idle_id;
     guint scroll_to_row_idle_id;
+    guint ensure_visible_idle_id;
 
     LibBalsaMailboxSearchIter *search_iter;
     BalsaIndexWidthPreference width_preference;
@@ -271,6 +272,11 @@ bndx_destroy(GObject * obj)
         bindex->scroll_to_row_idle_id = 0;
     }
 
+    if (bindex->ensure_visible_idle_id != 0) {
+        g_source_remove(bindex->ensure_visible_idle_id);
+        bindex->ensure_visible_idle_id = 0;
+    }
+
     /* Clean up any other idle handler sources */
     while (g_source_remove_by_user_data(bindex))
         /* Nothing */ ;
@@ -2820,7 +2826,7 @@ bndx_ensure_visible_idle(gpointer user_data)
         gtk_tree_path_free(path);
     }
 
-    g_object_unref(bindex);
+    bindex->ensure_visible_idle_id = 0;
 
     return G_SOURCE_REMOVE;
 }
@@ -2830,7 +2836,10 @@ balsa_index_ensure_visible(BalsaIndex * bindex)
 {
     g_return_if_fail(BALSA_IS_INDEX(bindex));
 
-    g_idle_add_full(G_PRIORITY_LOW, bndx_ensure_visible_idle, g_object_ref(bindex), NULL);
+    if (bindex->ensure_visible_idle_id == 0) {
+        bindex->ensure_visible_idle_id =
+            g_idle_add_full(G_PRIORITY_LOW, bndx_ensure_visible_idle, bindex, NULL);
+    }
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]