[gnome-documents/rhel-7.4: 14/16] application: Instantiate ShellSearchProvider only when registering



commit ca10b8d02486630db2f3de746ee4b885490cbaab
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Jun 8 16:12:15 2017 +0200

    application: Instantiate ShellSearchProvider only when registering
    
    Now that the --version flag was implemented using the
    handle_local_options virtual method, it is possible that the
    Application may exit without ever touching D-Bus. So it is a tad
    wasteful to instantiate the ShellSearchProvider when it is never going
    to be used. Since we are unreffing it in dbus_register, we might as
    well create it in dbus_register.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783548

 src/application.js |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 40a5dd0..2630e19 100644
--- a/src/application.js
+++ b/src/application.js
@@ -100,6 +100,7 @@ const Application = new Lang.Class({
         this.minersRunning = [];
         this._activationTimestamp = Gdk.CURRENT_TIME;
         this._extractPriority = null;
+        this._searchProvider = null;
 
         this.isBooks = isBooks;
 
@@ -120,10 +121,6 @@ const Application = new Lang.Class({
 
         this.add_main_option('version', 'v'.charCodeAt(0), GLib.OptionFlags.NONE, GLib.OptionArg.NONE,
                              _("Show the version of the program"), null);
-
-        this._searchProvider = new ShellSearchProvider.ShellSearchProvider();
-        this._searchProvider.connect('activate-result', Lang.bind(this, this._onActivateResult));
-        this._searchProvider.connect('launch-search', Lang.bind(this, this._onLaunchSearch));
     },
 
     _initGettingStarted: function() {
@@ -516,6 +513,10 @@ const Application = new Lang.Class({
     vfunc_dbus_register: function(connection, path) {
         this.parent(connection, path);
 
+        this._searchProvider = new ShellSearchProvider.ShellSearchProvider();
+        this._searchProvider.connect('activate-result', Lang.bind(this, this._onActivateResult));
+        this._searchProvider.connect('launch-search', Lang.bind(this, this._onLaunchSearch));
+
         this._searchProvider.export(connection);
         return true;
     },


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