[geary/mjog/766-search-deadlock] ConversationWebView: Avoid a deadlock cancelling search highlighting



commit ee2c66a3dcd315babfb8753736c45bf54e23c098
Author: Michael Gratton <mike vee net>
Date:   Fri Apr 3 21:50:17 2020 +1100

    ConversationWebView: Avoid a deadlock cancelling search highlighting
    
    According to the GLib.Cancellable docs, disconnecting a handler from
    within a handler will cause deadlock. So don't do that.
    
    Fixes #766

 src/client/conversation-viewer/conversation-web-view.vala | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/src/client/conversation-viewer/conversation-web-view.vala 
b/src/client/conversation-viewer/conversation-web-view.vala
index d22a836e..9832efa5 100644
--- a/src/client/conversation-viewer/conversation-web-view.vala
+++ b/src/client/conversation-viewer/conversation-web-view.vala
@@ -128,7 +128,10 @@ public class ConversationWebView : ClientWebView {
                 callback();
             });
         ulong cancelled_handler = cancellable.cancelled.connect(() => {
-                callback();
+                // Do this at idle since per the docs for
+                // GLib.Cancellable.disconnect, disconnecting a
+                // handler from within a handler causes a deadlock.
+                GLib.Idle.add(() => callback());
             });
 
         controller.search(


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