From 77817a394a967ff036db93dd380e64d0eed2417b Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Thu, 18 Jun 2015 16:37:04 -0700 Subject: 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] --- webhelper/webhelper2.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'webhelper/webhelper2.js') 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; -- cgit v1.2.3