[geary/mjog/558-webkit-shared-process: 7/11] Re-use WebKitGTK WebProcess between conversation loads



commit ec155ed707517ffea243da087e53ee42ea399b3b
Author: Michael Gratton <mike vee net>
Date:   Tue Nov 26 14:19:34 2019 +1100

    Re-use WebKitGTK WebProcess between conversation loads
    
    Since the WebProcess will be torn down when the last WebView using it is
    destroyed (not when the view object is deleted), we need to keep
    previous conversation widgets around until after the new conversation is
    loaded.

 src/client/conversation-viewer/conversation-viewer.vala | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-viewer.vala 
b/src/client/conversation-viewer/conversation-viewer.vala
index 8157e140..de5e185e 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -254,7 +254,10 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
                                         Application.ContactStore contacts,
                                         bool start_mark_timer)
         throws GLib.Error {
-        remove_current_list();
+        // Keep the old ScrolledWindow around long enough for its
+        // descendant web views to be kept so their WebProcess can be
+        // re-used.
+        var old_scroller = remove_current_list();
 
         ConversationListBox new_list = new ConversationListBox(
             conversation,
@@ -301,6 +304,9 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
         }
 
         yield new_list.load_conversation(scroll_to, query);
+
+        // Not strictly necessary, but keeps the compiler happy
+        old_scroller.destroy();
     }
 
     // Add a new conversation list to the UI
@@ -320,7 +326,7 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
     }
 
     // Remove any existing conversation list, cancelling its loading
-    private void remove_current_list() {
+    private Gtk.ScrolledWindow remove_current_list() {
         if (this.find_cancellable != null) {
             this.find_cancellable.cancel();
             this.find_cancellable = null;
@@ -332,15 +338,17 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
             this.current_list = null;
         }
 
+        var old_scroller = this.conversation_scroller;
         // XXX GTK+ Bug 778190 workaround
-        this.conversation_scroller.destroy(); // removes the list
+        this.conversation_page.remove(old_scroller);
         new_conversation_scroller();
+        return old_scroller;
     }
 
     private void new_conversation_scroller() {
         // XXX Work around for GTK+ Bug 778190: Instead of replacing
         // the Viewport that contains the current list, replace the
-        // complete ScrolledWindow. Need to put remove this method and
+        // complete ScrolledWindow. Need to remove this method and
         // put the settings back into conversation-viewer.ui when we
         // can rely on it being fixed again.
         Gtk.ScrolledWindow scroller = new Gtk.ScrolledWindow(null, null);


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