Merge lp:~abreu-alexandre/unity-webapps-qml/fail-safe-content-hub-bindings into lp:unity-webapps-qml

Proposed by Alexandre Abreu
Status: Merged
Approved by: Alexandre Abreu
Approved revision: 139
Merged at revision: 140
Proposed branch: lp:~abreu-alexandre/unity-webapps-qml/fail-safe-content-hub-bindings
Merge into: lp:unity-webapps-qml
Diff against target: 49 lines (+19/-4)
2 files modified
src/Ubuntu/UnityWebApps/UnityWebApps.qml (+2/-1)
src/Ubuntu/UnityWebApps/bindings/content-hub/backend/content-hub.js (+17/-3)
To merge this branch: bzr merge lp:~abreu-alexandre/unity-webapps-qml/fail-safe-content-hub-bindings
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alberto Mardegan (community) Approve
Review via email: mp+242834@code.launchpad.net

Commit message

Make sure that the content hub bindings are fail safe since the content hub package is a suggests (which is fine since it is not there by default on desktop).

Description of the change

Make sure that the content hub bindings are fail safe since the content hub package is a suggests (which is fine since it is not there by default on desktop).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alberto Mardegan (mardy) wrote :

I don't think that you need to import the QtQuick 2.0 module.
Also, I'm not sure if the exception will always be thrown, or if it's possible for Qt.createQmlObject() to return null without raising the exception; if so, you should check for its return value != null as well.

But I'm not sure of either points, so if you have already tested this and this is the correct solution, +1 from me.

review: Approve
Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

> I don't think that you need to import the QtQuick 2.0 module.

I didn't initially, but it seems to be required to known about QtObject,

> Also, I'm not sure if the exception will always be thrown, or if it's possible
> for Qt.createQmlObject() to return null without raising the exception; if so,
> you should check for its return value != null as well.

+1

> But I'm not sure of either points, so if you have already tested this and this
> is the correct solution, +1 from me.

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

> I don't think that you need to import the QtQuick 2.0 module.

I didn't initially, but it seems to be required to known about QtObject,

> Also, I'm not sure if the exception will always be thrown, or if it's possible
> for Qt.createQmlObject() to return null without raising the exception; if so,
> you should check for its return value != null as well.

+1

> But I'm not sure of either points, so if you have already tested this and this
> is the correct solution, +1 from me.

139. By Alexandre Abreu

updates

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
140. By Alexandre Abreu

revert change

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.qml'
--- src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-11-21 21:12:26 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-12-01 15:44:28 +0000
@@ -784,7 +784,8 @@
784 return AlarmApiBackend.createAlarmApi(UnityBackends.backendDelegate)784 return AlarmApiBackend.createAlarmApi(UnityBackends.backendDelegate)
785 }),785 }),
786786
787 ContentHub: ContentHubApiBackend.createContentHubApi(UnityBackends.backendDelegate),787 ContentHub: ContentHubApiBackend.createContentHubApi(
788 UnityBackends.backendDelegate, webapps),
788789
789 RuntimeApi: __injectResourceIfExtraApisAreEnabled(function() {790 RuntimeApi: __injectResourceIfExtraApisAreEnabled(function() {
790 return RuntimeApiBackend.createRuntimeApi(UnityBackends.backendDelegate)791 return RuntimeApiBackend.createRuntimeApi(UnityBackends.backendDelegate)
791792
=== modified file 'src/Ubuntu/UnityWebApps/bindings/content-hub/backend/content-hub.js'
--- src/Ubuntu/UnityWebApps/bindings/content-hub/backend/content-hub.js 2014-06-17 13:53:49 +0000
+++ src/Ubuntu/UnityWebApps/bindings/content-hub/backend/content-hub.js 2014-12-01 15:44:28 +0000
@@ -16,15 +16,29 @@
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */17 */
1818
19.import Ubuntu.Content 0.1 as ContentHubBridge
20
21/**19/**
22 *20 *
23 * ContentHub API backend binding21 * ContentHub API backend binding
24 *22 *
25 */23 */
2624
27function createContentHubApi(backendDelegate, accessPolicy) {25function createContentHubApi(backendDelegate, parent) {
26
27 var bridge = null
28 try {
29 bridge = Qt.createQmlObject(
30 'import QtQuick 2.0; import Ubuntu.Content 0.1 as ContentHubBridge; \
31 QtObject { property var hub: ContentHubBridge }', parent)
32 }
33 catch(e) { }
34
35 if (!bridge) {
36 console.log('Could not create ContentHub backend (does not appear to be installed)')
37 return {};
38 }
39
40 var ContentHubBridge = bridge.hub;
41
28 var PLUGIN_URI = 'Ubuntu.Content';42 var PLUGIN_URI = 'Ubuntu.Content';
29 var VERSION = 0.1;43 var VERSION = 0.1;
3044

Subscribers

People subscribed via source and target branches

to all changes: