[geary/wip/problem-report-logs: 9/22] Add Geary.Logging.clear method, call it on app shutdown



commit 496eb3de1dbbcc4b3dd6c86aad259a3b431137a2
Author: Michael Gratton <mike vee net>
Date:   Sun Jun 30 16:43:15 2019 +1000

    Add Geary.Logging.clear method, call it on app shutdown

 src/client/application/geary-application.vala |  2 ++
 src/engine/api/geary-logging.vala             | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
---
diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala
index de894601..e6e078f4 100644
--- a/src/client/application/geary-application.vala
+++ b/src/client/application/geary-application.vala
@@ -661,6 +661,8 @@ public class GearyApplication : Gtk.Application {
         }
 
         quit();
+
+        Geary.Logging.clear();
         Util.Date.terminate();
     }
 
diff --git a/src/engine/api/geary-logging.vala b/src/engine/api/geary-logging.vala
index 3d95a8c7..8eec7954 100644
--- a/src/engine/api/geary-logging.vala
+++ b/src/engine/api/geary-logging.vala
@@ -350,6 +350,23 @@ public void init() {
     max_log_length = DEFAULT_MAX_LOG_BUFFER_LENGTH;
 }
 
+/**
+ * Clears all log records.
+ *
+ * Since log records hold references to Geary engine objects, it may
+ * be desirable to clear the records prior to shutdown so that the
+ * objects can be destroyed.
+ */
+public void clear() {
+    record_lock.lock();
+
+    first_record = null;
+    last_record = null;
+    log_length = 0;
+    
+    record_lock.unlock();
+}
+
 /**
  * Replaces the current logging flags with flags.  Use Geary.Logging.Flag.NONE to clear all
  * logging flags.


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