[geary/mjog/650-old-val-0-glib-critical] Geary.Util.Source: Fix GLib `old_val > 0` critical



commit d8dfc7d150bcd1456e256614ec39847c900a16bf
Author: Michael Gratton <mike vee net>
Date:   Wed Mar 25 10:07:02 2020 +1100

    Geary.Util.Source: Fix GLib `old_val > 0` critical
    
    If a source object prints a log message from a destructor the
    engine's logging hander will attempt to ref it despite the object
    bing finalised, resulting in the critical.
    
    Fixes #650

 src/engine/util/util-logging.vala | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/src/engine/util/util-logging.vala b/src/engine/util/util-logging.vala
index 4161aad7..f12cb4c0 100644
--- a/src/engine/util/util-logging.vala
+++ b/src/engine/util/util-logging.vala
@@ -221,7 +221,12 @@ public interface Geary.Logging.Source : GLib.Object {
             Context context = Context(Logging.DOMAIN, flags, levels, fmt, args);
             Source? decorated = this;
             while (decorated != null) {
-                context.append_source(decorated);
+                // Don't attempt to ref an object is in the middle of
+                // being destructed, which can happen when logging
+                // from the destructor.
+                if (decorated.ref_count > 0) {
+                    context.append_source(decorated);
+                }
                 decorated = decorated.logging_parent;
             }
 


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