summaryrefslogtreecommitdiff
path: root/webhelper
diff options
context:
space:
mode:
authorPhilip Chimento <philip@endlessm.com>2015-06-18 16:37:04 -0700
committerPhilip Chimento <philip@endlessm.com>2015-06-18 16:37:04 -0700
commit77817a394a967ff036db93dd380e64d0eed2417b (patch)
tree667915ee66749247197e80658870fd2dee5994c3 /webhelper
parent8237b2e794875b3564857ead749c9b65358c75f6 (diff)
Use ProxyConstructor asynchronously
I did not realize that the constructor returned from Gio.DBus.makeProxyWrapper did a synchronous DBus call unless you passed it a callback. It should be used asynchronously. [endlessm/eos-sdk#3296]
Diffstat (limited to 'webhelper')
-rw-r--r--webhelper/webhelper2.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/webhelper/webhelper2.js b/webhelper/webhelper2.js
index b5f87f8..5917375 100644
--- a/webhelper/webhelper2.js
+++ b/webhelper/webhelper2.js
@@ -391,14 +391,22 @@ const WebHelper = new Lang.Class({
// name appeared
let webview_object_path = DBUS_WEBVIEW_EXPORT_PATH +
webview.get_page_id();
- let proxy = new this._ProxyConstructor(connection,
- this._extension_name, webview_object_path);
- if (cancellable)
- proxy.TranslateRemote(cancellable,
- this._translate_callback.bind(this, task));
- else
- proxy.TranslateRemote(this._translate_callback.bind(this,
- task));
+ // Warning: this._ProxyConstructor will do a synchronous
+ // operation unless you pass in a callback
+ new this._ProxyConstructor(connection, this._extension_name,
+ webview_object_path, (proxy, error) =>
+ {
+ if (error) {
+ this._translate_callback(task, null, error);
+ return;
+ }
+ if (cancellable)
+ proxy.TranslateRemote(cancellable,
+ this._translate_callback.bind(this, task));
+ else
+ proxy.TranslateRemote(this._translate_callback.bind(this,
+ task));
+ }, cancellable);
},
null); // do nothing when name vanishes
return task;