[gnome-latex] DocumentStructure: remove idle GSource when object destroyed



commit 56b59020f14540a87f1f8e111cb125e0f3d28371
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed May 9 13:31:01 2018 +0200

    DocumentStructure: remove idle GSource when object destroyed
    
    To try to fix:
    https://gitlab.gnome.org/GNOME/gnome-latex/issues/57
    
    But it doesn't fix the crash.

 src/document_structure.vala | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/src/document_structure.vala b/src/document_structure.vala
index 63e2dc8..a576f08 100644
--- a/src/document_structure.vala
+++ b/src/document_structure.vala
@@ -59,6 +59,8 @@ public class DocumentStructure : GLib.Object
 
     private static string[] _section_names = null;
 
+    private uint _idle_id = 0;
+
     public bool parsing_done { get; private set; default = false; }
 
     public DocumentStructure (Document doc)
@@ -87,6 +89,15 @@ public class DocumentStructure : GLib.Object
         }
     }
 
+    ~DocumentStructure ()
+    {
+        if (_idle_id != 0)
+        {
+            Source.remove (_idle_id);
+            _idle_id = 0;
+        }
+    }
+
     public void parse ()
     {
         // reset
@@ -98,9 +109,17 @@ public class DocumentStructure : GLib.Object
         _end_document_mark = null;
         clear_all_structure_marks ();
 
-        Idle.add (() =>
+        if (_idle_id != 0)
+            Source.remove (_idle_id);
+
+        _idle_id = Idle.add (() =>
         {
-            return parse_impl ();
+            bool ret = parse_impl ();
+
+            if (!ret)
+                _idle_id = 0;
+
+            return ret;
         });
     }
 


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