[devhelp] Book: create DhCompletion when book enabled



commit 188bb01145825abcc9e5051282df411da538dc55
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Jan 6 21:19:34 2018 +0100

    Book: create DhCompletion when book enabled
    
    A DhBook is initially enabled, but dh_book_set_enabled() is anyway
    called after the DhBook is created and when it is enabled in the
    preferences.
    
    When GCompletion was used it was done similarly, the GCompletion was
    created upfront, and at the time of the first completion the GCompletion
    was already created.

 src/dh-book.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/dh-book.c b/src/dh-book.c
index 91960ea..e351da2 100644
--- a/src/dh-book.c
+++ b/src/dh-book.c
@@ -573,6 +573,15 @@ dh_book_set_enabled (DhBook   *book,
 
         enabled = enabled != FALSE;
 
+        /* Create DhCompletion, because if all the DhCompletion objects need to
+         * be created (synchronously) at the time of the first completion, it
+         * can make the GUI not responsive (measured time was for example 40ms
+         * to create the DhCompletion's for 17 books, which is not a lot of
+         * books). On application startup it is less a problem.
+         */
+        if (enabled)
+                dh_book_get_completion (book);
+
         if (priv->enabled != enabled) {
                 priv->enabled = enabled;
                 g_signal_emit (book,


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