[geary/wip/geary-inspector: 37/38] Use MainContext.invoke to handle appending new log messages



commit 62e52e247cb1ccf6cbc4acc94af2a4649be4f2a9
Author: Michael Gratton <mike vee net>
Date:   Sun Apr 7 18:09:29 2019 +1000

    Use MainContext.invoke to handle appending new log messages
    
    This ensures the correct approach is used, regardless of what thread
    and context is currently executing.

 src/client/components/components-inspector.vala | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
---
diff --git a/src/client/components/components-inspector.vala b/src/client/components/components-inspector.vala
index 3bb4e0c0..0785fa0a 100644
--- a/src/client/components/components-inspector.vala
+++ b/src/client/components/components-inspector.vala
@@ -382,15 +382,10 @@ public class Components.Inspector : Gtk.ApplicationWindow {
 
     private void on_log_record(Geary.Logging.Record record) {
         if (this.update_logs) {
-            if (GLib.MainContext.default() ==
-                GLib.MainContext.get_thread_default()) {
-                append_record(record);
-            } else {
-                GLib.Idle.add(() => {
-                        append_record(record);
-                        return GLib.Source.REMOVE;
-                    });
-            }
+            GLib.MainContext.default().invoke(() => {
+                    append_record(record);
+                    return GLib.Source.REMOVE;
+                });
         } else if (this.first_pending == null) {
             this.first_pending = record;
         }


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