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
This commit is contained in:
Michael Gratton 2020-03-25 10:07:02 +11:00 committed by Michael James Gratton
parent 8dfa262481
commit 8c43288bd0

View file

@ -219,7 +219,10 @@ public interface Geary.Logging.Source : GLib.Object {
va_list args) {
if (flags == ALL || Logging.get_flags().is_any_set(flags)) {
Context context = Context(Logging.DOMAIN, flags, levels, fmt, args);
Source? decorated = this;
// Don't attempt to this object if it is in the middle of
// being destructed, which can happen when logging from
// the destructor.
Source? decorated = (this.ref_count > 0) ? this : this.logging_parent;
while (decorated != null) {
context.append_source(decorated);
decorated = decorated.logging_parent;