[gnome-shell/gnome-3-8] status/keyboard: Stop destroying the IBusBus object



commit ff2e44de5398a59e93f13d02172339bcb9f95bed
Author: Rui Matos <tiagomatos gmail com>
Date:   Mon Apr 29 01:17:06 2013 +0200

    status/keyboard: Stop destroying the IBusBus object
    
    This is a singleton object inside libibus which means that if we
    destroy it (e.g. because ibus-daemon got restarted) then, other
    library users, like the ibus gtk+ IM module that we also use
    in-process, will break.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=699189

 js/ui/status/keyboard.js |   26 +++++++++-----------------
 1 files changed, 9 insertions(+), 17 deletions(-)
---
diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js
index 3dc173b..2e85561 100644
--- a/js/ui/status/keyboard.js
+++ b/js/ui/status/keyboard.js
@@ -45,26 +45,24 @@ const IBusManager = new Lang.Class({
         this._readyCallback = readyCallback;
         this._candidatePopup = new IBusCandidatePopup.CandidatePopup();
 
-        this._ibus = null;
         this._panelService = null;
         this._engines = {};
         this._ready = false;
         this._registerPropertiesId = 0;
         this._currentEngineName = null;
 
-        this._nameWatcherId = Gio.DBus.session.watch_name(IBus.SERVICE_IBUS,
-                                                          Gio.BusNameWatcherFlags.NONE,
-                                                          Lang.bind(this, this._onNameAppeared),
-                                                          Lang.bind(this, this._clear));
+        this._ibus = IBus.Bus.new_async();
+        this._ibus.connect('connected', Lang.bind(this, this._onConnected));
+        this._ibus.connect('disconnected', Lang.bind(this, this._clear));
+        // Need to set this to get 'global-engine-changed' emitions
+        this._ibus.set_watch_ibus_signal(true);
+        this._ibus.connect('global-engine-changed', Lang.bind(this, this._engineChanged));
     },
 
     _clear: function() {
         if (this._panelService)
             this._panelService.destroy();
-        if (this._ibus)
-            this._ibus.destroy();
 
-        this._ibus = null;
         this._panelService = null;
         this._candidatePopup.setPanelService(null);
         this._engines = {};
@@ -76,18 +74,12 @@ const IBusManager = new Lang.Class({
             this._readyCallback(false);
     },
 
-    _onNameAppeared: function() {
-        this._ibus = IBus.Bus.new_async();
-        this._ibus.connect('connected', Lang.bind(this, this._onConnected));
-    },
-
     _onConnected: function() {
         this._ibus.list_engines_async(-1, null, Lang.bind(this, this._initEngines));
         this._ibus.request_name_async(IBus.SERVICE_PANEL,
                                       IBus.BusNameFlag.REPLACE_EXISTING,
                                       -1, null,
                                       Lang.bind(this, this._initPanelService));
-        this._ibus.connect('disconnected', Lang.bind(this, this._clear));
     },
 
     _initEngines: function(ibus, result) {
@@ -109,9 +101,6 @@ const IBusManager = new Lang.Class({
             this._panelService = new IBus.PanelService({ connection: this._ibus.get_connection(),
                                                          object_path: IBus.PATH_PANEL });
             this._candidatePopup.setPanelService(this._panelService);
-            // Need to set this to get 'global-engine-changed' emitions
-            this._ibus.set_watch_ibus_signal(true);
-            this._ibus.connect('global-engine-changed', Lang.bind(this, this._engineChanged));
             this._panelService.connect('update-property', Lang.bind(this, this._updateProperty));
             // If an engine is already active we need to get its properties
             this._ibus.get_global_engine_async(-1, null, Lang.bind(this, function(i, result) {
@@ -140,6 +129,9 @@ const IBusManager = new Lang.Class({
     },
 
     _engineChanged: function(bus, engineName) {
+        if (!this._ready)
+            return;
+
         this._currentEngineName = engineName;
 
         if (this._registerPropertiesId != 0)


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