[gnome-documents] application: Instantiate ShellSearchProvider only when registering



commit 930073387bf3f37152a5bee7971f27e7e447c44e
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 77495de..ad7e052 100644
--- a/src/application.js
+++ b/src/application.js
@@ -103,6 +103,7 @@ const Application = new Lang.Class({
         this.minersRunning = [];
         this._activationTimestamp = Gdk.CURRENT_TIME;
         this._extractPriority = null;
+        this._searchProvider = null;
 
         this.isBooks = isBooks;
 
@@ -123,10 +124,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() {
@@ -448,6 +445,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]