Merge lp:~dandrader/qtubuntu/betterSessionName into lp:qtubuntu

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Gerry Boland
Approved revision: no longer in the source branch.
Merged at revision: 322
Proposed branch: lp:~dandrader/qtubuntu/betterSessionName
Merge into: lp:qtubuntu
Diff against target: 104 lines (+44/-8)
2 files modified
src/ubuntumirclient/integration.cpp (+40/-6)
src/ubuntumirclient/integration.h (+4/-2)
To merge this branch: bzr merge lp:~dandrader/qtubuntu/betterSessionName
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Approve
Gerry Boland (community) Approve
Review via email: mp+296198@code.launchpad.net

Commit message

Generate better mir session names

Try to come up with some meaningful session name to uniquely identify this session,
helping with shell debugging

Description of the change

Immensely helpful to help make sense of unity8.log when debugging multiple/nested prompt sessions use cases such as in bug 1586219.

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:317
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/63/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/1759
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1785
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1732
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1732
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1732
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1725
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1725/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1725
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1725/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1725
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1725/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1725
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1725/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1725
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1725/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1725
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1725/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1725
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1725/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1725
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1725/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1725
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1725/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/63/rebuild

review: Approve (continuous-integration)
Revision history for this message
Nick Dedekind (nick-dedekind) :
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

On 01/06/2016 09:48, Nick Dedekind wrote:
>> +QByteArray UbuntuClientIntegration::generateSessionName(QStringList &args)
>> >+{
> Perhaps use QApplication::applicationName first? I actually had a branch for this about a thousand years ago, but it never went anywhere.
>

QApplication::applicationName might not be set yet when
QPlatformIntegration is created (which is really early). It can be set
or even changed at any time by calling
QCoreApplicaiton::setApplicationName, and we would have not way of
updating your session id to follow those changes. So the only thing sure
to exist at QPlatformIntegration creation is the application arguments.

Revision history for this message
Gerry Boland (gerboland) wrote :

+for (int i = 0; i < args.count(); ++i) {
+ QString arg = args[i];
We have Q_FOREACH

Do you really need to read the FileInfo object? Why not just drop the ".qml" from the file name?

+ u_application_id_new_from_stringn(sessionName.data(), sessionName.count());
Does the api expect sessionName to always exist, or will it make a copy itself?

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

On 01/06/2016 12:01, Gerry Boland wrote:
> Review: Needs Fixing
>
> +for (int i = 0; i < args.count(); ++i) {
> + QString arg = args[i];
> We have Q_FOREACH

I personally find this macro ugly, but if you fancy it...
But it is less code and thus less error prone. Done.

> Do you really need to read the FileInfo object? Why not just drop the ".qml" from the file name?
Yes. The argument could be a full file path like this:

/foo/bar/whatever/zumba.qml

Which would make for a cumbersome session name. QFileInfo neatly and
safely parses that filepath for me.

I like the ".qml" suffix as it tells us it's a plain qml app run via
qmlscene.

> + u_application_id_new_from_stringn(sessionName.data(), sessionName.count());
> Does the api expect sessionName to always exist, or will it make a copy itself?

It makes a copy. What a horrible API it would be otherwise.

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:318
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/64/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/1762
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1788
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1735
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1735
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1735
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1728
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1728/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1728
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1728/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1728
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1728/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1728
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1728/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1728
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1728/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1728
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1728/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1728
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1728/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1728
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1728/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1728
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1728/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/64/rebuild

review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

> > Do you really need to read the FileInfo object? Why not just drop the ".qml"
> from the file name?
> Yes. The argument could be a full file path like this:
>
> /foo/bar/whatever/zumba.qml
>
> Which would make for a cumbersome session name. QFileInfo neatly and
> safely parses that filepath for me.
>
> I like the ".qml" suffix as it tells us it's a plain qml app run via
> qmlscene.

Yeah, that's ok. I just want to keep app startup light, using QFileInfo to parse a file name just strikes me as heavy for something that only those reading file logs will appreciate. But I won't block on that.

> > + u_application_id_new_from_stringn(sessionName.data(),
> sessionName.count());
> > Does the api expect sessionName to always exist, or will it make a copy
> itself?
>
> It makes a copy. What a horrible API it would be otherwise.

You never know :)

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

On 01/06/2016 12:58, Gerry Boland wrote:
> Yeah, that's ok. I just want to keep app startup light, using QFileInfo to parse a file name just strikes me as heavy for something that only those reading file logs will appreciate. But I won't block on that.

QFileInfo creation looks pretty tame and lightweight. It pretty much
just stores the given filepath in a internal string.

The only real code we execute happens when we call QFileInfo::fileName,
where it essentially finds the last separator char in the string and
then "return m_filePath.mid(m_lastSeparator + 1);".

Revision history for this message
Gerry Boland (gerboland) wrote :

Ok, thanks for checking that. Change looks good to me!

review: Approve
322. By Daniel d'Andrada

Generate better mir session names

Try to come up with some meaningful session name to uniquely identify this session,
helping with shell debugging

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:318
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/69/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/1818
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1843
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1784
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1784
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1784
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1774
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1774/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1774
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1774/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1774
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1774/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1774
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1774/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1774
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1774/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1774
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1774/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1774
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1774/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1774
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1774/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1774
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1774/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/69/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ubuntumirclient/integration.cpp'
2--- src/ubuntumirclient/integration.cpp 2016-04-28 14:44:18 +0000
3+++ src/ubuntumirclient/integration.cpp 2016-06-03 13:56:35 +0000
4@@ -28,6 +28,7 @@
5 #include "window.h"
6
7 // Qt
8+#include <QFileInfo>
9 #include <QGuiApplication>
10 #include <private/qguiapplication_p.h>
11 #include <qpa/qplatformnativeinterface.h>
12@@ -77,8 +78,12 @@
13 , mClipboard(new UbuntuClipboard)
14 , mScaleFactor(1.0)
15 {
16- setupOptions();
17- setupDescription();
18+ {
19+ QStringList args = QCoreApplication::arguments();
20+ setupOptions(args);
21+ QByteArray sessionName = generateSessionName(args);
22+ setupDescription(sessionName);
23+ }
24
25 // Create new application instance
26 mInstance = u_application_instance_new_from_description_with_options(mDesc, mOptions);
27@@ -161,9 +166,8 @@
28 return mServices;
29 }
30
31-void UbuntuClientIntegration::setupOptions()
32+void UbuntuClientIntegration::setupOptions(QStringList &args)
33 {
34- QStringList args = QCoreApplication::arguments();
35 int argc = args.size() + 1;
36 char **argv = new char*[argc];
37 for (int i = 0; i < argc - 1; i++)
38@@ -177,10 +181,11 @@
39 delete [] argv;
40 }
41
42-void UbuntuClientIntegration::setupDescription()
43+void UbuntuClientIntegration::setupDescription(QByteArray &sessionName)
44 {
45 mDesc = u_application_description_new();
46- UApplicationId* id = u_application_id_new_from_stringn("QtUbuntu", 8);
47+
48+ UApplicationId* id = u_application_id_new_from_stringn(sessionName.data(), sessionName.count());
49 u_application_description_set_application_id(mDesc, id);
50
51 UApplicationLifecycleDelegate* delegate = u_application_lifecycle_delegate_new();
52@@ -190,6 +195,35 @@
53 u_application_description_set_application_lifecycle_delegate(mDesc, delegate);
54 }
55
56+QByteArray UbuntuClientIntegration::generateSessionName(QStringList &args)
57+{
58+ // Try to come up with some meaningful session name to uniquely identify this session,
59+ // helping with shell debugging
60+
61+ if (args.count() == 0) {
62+ return QByteArray("QtUbuntu");
63+ } if (args[0].contains("qmlscene")) {
64+ return generateSessionNameFromQmlFile(args);
65+ } else {
66+ // use the executable name
67+ QFileInfo fileInfo(args[0]);
68+ return fileInfo.fileName().toLocal8Bit();
69+ }
70+}
71+
72+QByteArray UbuntuClientIntegration::generateSessionNameFromQmlFile(QStringList &args)
73+{
74+ Q_FOREACH (QString arg, args) {
75+ if (arg.endsWith(".qml")) {
76+ QFileInfo fileInfo(arg);
77+ return fileInfo.fileName().toLocal8Bit();
78+ }
79+ }
80+
81+ // give up
82+ return "qmlscene";
83+}
84+
85 QPlatformWindow* UbuntuClientIntegration::createPlatformWindow(QWindow* window) const
86 {
87 return const_cast<UbuntuClientIntegration*>(this)->createPlatformWindow(window);
88
89=== modified file 'src/ubuntumirclient/integration.h'
90--- src/ubuntumirclient/integration.h 2016-04-28 14:09:54 +0000
91+++ src/ubuntumirclient/integration.h 2016-06-03 13:56:35 +0000
92@@ -76,8 +76,10 @@
93 void destroyScreen(UbuntuScreen *screen);
94
95 private:
96- void setupOptions();
97- void setupDescription();
98+ void setupOptions(QStringList &args);
99+ void setupDescription(QByteArray &sessionName);
100+ static QByteArray generateSessionName(QStringList &args);
101+ static QByteArray generateSessionNameFromQmlFile(QStringList &args);
102
103 UbuntuNativeInterface* mNativeInterface;
104 QPlatformFontDatabase* mFontDb;

Subscribers

People subscribed via source and target branches