[geary/mjog/650-old-val-0-glib-critical] Geary.Util.Logging.Source: Fix GLib `old_val > 0` critical
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/650-old-val-0-glib-critical] Geary.Util.Logging.Source: Fix GLib `old_val > 0` critical
- Date: Wed, 25 Mar 2020 00:15:45 +0000 (UTC)
commit 7b5866f39929dd22022d9583113a1cb692dabeea
Author: Michael Gratton <mike vee net>
Date: Wed Mar 25 10:07:02 2020 +1100
Geary.Util.Logging.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]