Merge lp:~fboucault/ubuntu-ui-toolkit/report_content_orientation into lp:ubuntu-ui-toolkit

Proposed by Florian Boucault
Status: Merged
Approved by: Zoltan Balogh
Approved revision: 653
Merged at revision: 658
Proposed branch: lp:~fboucault/ubuntu-ui-toolkit/report_content_orientation
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 79 lines (+36/-0)
3 files modified
modules/Ubuntu/Components/OrientationHelper.qml (+8/-0)
modules/Ubuntu/Components/plugin/plugin.cpp (+22/-0)
modules/Ubuntu/Components/plugin/plugin.h (+6/-0)
To merge this branch: bzr merge lp:~fboucault/ubuntu-ui-toolkit/report_content_orientation
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu SDK team Pending
Review via email: mp+176740@code.launchpad.net

Commit message

OrientationHelper: report the current orientation of the application via QWindow::contentOrientation.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
649. By Florian Boucault

Fix CI failure.

Revision history for this message
Florian Boucault (fboucault) wrote :

Extra qDebug statement will have to be removed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
651. By Florian Boucault

Empty commit

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Thomas Moenicke (thomas-moenicke) wrote :

I sometimes get crashes in UbuntuComponentsPlugin::setWindowContextProperty because m_context does not seem to be constructed yet. I suggest adding an explicit constructor that initializes m_context to 0, to have it in a defined state until initializeEngine() is called.

Revision history for this message
Florian Boucault (fboucault) wrote :

> I sometimes get crashes in UbuntuComponentsPlugin::setWindowContextProperty
> because m_context does not seem to be constructed yet. I suggest adding an
> explicit constructor that initializes m_context to 0, to have it in a defined
> state until initializeEngine() is called.

Can you provide the stacktrace of the crash you are getting?

Revision history for this message
Thomas Moenicke (thomas-moenicke) wrote :

After doing some more investigation, I can verify the m_context object gets instantiated correctly before setWindowContextProperty() is called. The issue is only for the maliit-server itself when showing up, the context object is invalid or dangled. This fixes it for me:
https://code.launchpad.net/~thomas-moenicke/phablet-extras/ubuntu-sdk-report-content-orientation

652. By Florian Boucault

Fix segmentation fault.

653. By Florian Boucault

Removed debugging.

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/OrientationHelper.qml'
2--- modules/Ubuntu/Components/OrientationHelper.qml 2013-07-09 15:42:50 +0000
3+++ modules/Ubuntu/Components/OrientationHelper.qml 2013-07-26 11:39:31 +0000
4@@ -91,6 +91,14 @@
5
6 Component.onCompleted: orientationTransition.enabled = transitionEnabled
7
8+ /*!
9+ \internal
10+
11+ Report the current orientation of the application via QWindow::contentOrientation.
12+ http://qt-project.org/doc/qt-5.0/qtgui/qwindow.html#contentOrientation-prop
13+ */
14+ onOrientationAngleChanged: window.contentOrientation = Screen.orientation
15+
16 Item {
17 id: stateWrapper
18
19
20=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
21--- modules/Ubuntu/Components/plugin/plugin.cpp 2013-07-10 12:27:23 +0000
22+++ modules/Ubuntu/Components/plugin/plugin.cpp 2013-07-26 11:39:31 +0000
23@@ -100,6 +100,26 @@
24 }
25 }
26
27+void UbuntuComponentsPlugin::registerWindowContextProperty()
28+{
29+ setWindowContextProperty(QGuiApplication::focusWindow());
30+
31+ // listen to QGuiApplication::focusWindowChanged
32+ QGuiApplication* application = static_cast<QGuiApplication*>(QCoreApplication::instance());
33+ QObject::connect(application, SIGNAL(focusWindowChanged(QWindow*)),
34+ this, SLOT(setWindowContextProperty(QWindow*)));
35+
36+}
37+
38+void UbuntuComponentsPlugin::setWindowContextProperty(QWindow* focusWindow)
39+{
40+ QQuickView* view = qobject_cast<QQuickView*>(focusWindow);
41+
42+ if (view != NULL) {
43+ view->rootContext()->setContextProperty("window", view);
44+ }
45+}
46+
47 void UbuntuComponentsPlugin::registerTypes(const char *uri)
48 {
49 Q_ASSERT(uri == QLatin1String("Ubuntu.Components"));
50@@ -164,4 +184,6 @@
51 Qt::LandscapeOrientation |
52 Qt::InvertedPortraitOrientation |
53 Qt::InvertedLandscapeOrientation);
54+
55+ registerWindowContextProperty();
56 }
57
58=== modified file 'modules/Ubuntu/Components/plugin/plugin.h'
59--- modules/Ubuntu/Components/plugin/plugin.h 2013-07-01 05:54:33 +0000
60+++ modules/Ubuntu/Components/plugin/plugin.h 2013-07-26 11:39:31 +0000
61@@ -22,6 +22,8 @@
62 #include <QtQml/QQmlEngine>
63 #include <QtQml/QQmlExtensionPlugin>
64
65+class QWindow;
66+
67 class UbuntuComponentsPlugin : public QQmlExtensionPlugin
68 {
69 Q_OBJECT
70@@ -32,6 +34,10 @@
71 void initializeEngine(QQmlEngine *engine, const char *uri);
72 QUrl baseUrl(QStringList importPathList, const char* uri);
73 void registerQmlSingletonType(QQmlEngine *engine, const char* uri, const char* typeName, const char* qmlFile);
74+
75+private Q_SLOTS:
76+ void registerWindowContextProperty();
77+ void setWindowContextProperty(QWindow* focusWindow);
78 };
79 #endif // UBUNTU_COMPONENTS_PLUGIN_H
80

Subscribers

People subscribed via source and target branches

to status/vote changes: