[geary/mjog/misc-fixes] Blacklist logging GTK warning about null action targets



commit 62edbed63c7422d6c96134f4e992d7da7695756c
Author: Michael Gratton <mike vee net>
Date:   Wed Dec 4 11:35:58 2019 +0800

    Blacklist logging GTK warning about null action targets
    
    GAction does not support disabling parameterised actions
    with specific values, but GTK complains if the parameter is
    set to null to achieve the same effect, and they aren't
    interested in supporting that: GNOME/gtk!1151
    
    Move GDKPixbuf blacklisting to log handler as well, target it more
    precisely.

 .../components/components-inspector-log-view.vala   | 10 +++-------
 src/engine/api/geary-logging.vala                   | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/src/client/components/components-inspector-log-view.vala 
b/src/client/components/components-inspector-log-view.vala
index c1e3d996..f3c401ad 100644
--- a/src/client/components/components-inspector-log-view.vala
+++ b/src/client/components/components-inspector-log-view.vala
@@ -211,15 +211,11 @@ public class Components.InspectorLogView : Gtk.Grid {
     }
 
     private inline bool should_append(Geary.Logging.Record record) {
-        // Blacklist GdkPixbuf since it spams us e.g. when window
-        // focus changes, including between MainWindow and the
-        // Inspector, which is very annoying.
         record.fill_well_known_sources();
         return (
-            record.domain != "GdkPixbuf" &&
-            (record.account == null ||
-             this.account_filter == null ||
-             record.account.information == this.account_filter)
+            record.account == null ||
+            this.account_filter == null ||
+            record.account.information == this.account_filter
         );
     }
 
diff --git a/src/engine/api/geary-logging.vala b/src/engine/api/geary-logging.vala
index 07346156..11f7b09d 100644
--- a/src/engine/api/geary-logging.vala
+++ b/src/engine/api/geary-logging.vala
@@ -494,6 +494,9 @@ public void log_to(FileStream? stream) {
 public GLib.LogWriterOutput default_log_writer(GLib.LogLevelFlags levels,
                                                GLib.LogField[] fields) {
     Record record = new Record(fields, levels, GLib.get_real_time());
+    if (should_blacklist(record)) {
+        return GLib.LogWriterOutput.HANDLED;
+    }
 
     // Keep the old first record so we don't cause any records to be
     // finalised while under the lock, leading to deadlock if
@@ -537,6 +540,24 @@ public GLib.LogWriterOutput default_log_writer(GLib.LogLevelFlags levels,
     return GLib.LogWriterOutput.HANDLED;
 }
 
+private bool should_blacklist(Record record) {
+    return (
+        // GdkPixbuf spams us e.g. when window focus changes,
+        // including between MainWindow and the Inspector, which is
+        // very annoying.
+        (record.levels == GLib.LogLevelFlags.LEVEL_DEBUG &&
+         record.domain == "GdkPixbuf") ||
+        // GAction does not support disabling parameterised actions
+        // with specific values, but GTK complains if the parameter is
+        // set to null to achieve the same effect, and they aren't
+        // interested in supporting that: GNOME/gtk!1151
+        (record.levels == GLib.LogLevelFlags.LEVEL_WARNING &&
+         record.domain == "Gtk" &&
+         record.message.has_prefix("actionhelper:") &&
+         record.message.has_suffix("target type NULL)"))
+    );
+}
+
 private inline void write_record(Record record,
                                  GLib.LogLevelFlags levels) {
     // Print a log message to the stream if configured, or if the


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