Merge lp:~dandrader/qtubuntu/betterSessionName into lp:qtubuntu
- betterSessionName
- Merge into trunk
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 |
Related bugs: |
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.
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
Nick Dedekind (nick-dedekind) : | # |
Daniel d'Andrada (dandrader) wrote : | # |
On 01/06/2016 09:48, Nick Dedekind wrote:
>> +QByteArray UbuntuClientInt
>> >+{
> Perhaps use QApplication:
>
QApplication:
QPlatformIntegr
or even changed at any time by calling
QCoreApplicaito
updating your session id to follow those changes. So the only thing sure
to exist at QPlatformIntegr
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_
Does the api expect sessionName to always exist, or will it make a copy itself?
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/
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_
> 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.
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:318
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
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/
>
> 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_
> sessionName.
> > 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 :)
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:
where it essentially finds the last separator char in the string and
then "return m_filePath.
Gerry Boland (gerboland) wrote : | # |
Ok, thanks for checking that. Change looks good to me!
- 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
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:318
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
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 | 28 | #include "window.h" | 28 | #include "window.h" |
6 | 29 | 29 | ||
7 | 30 | // Qt | 30 | // Qt |
8 | 31 | #include <QFileInfo> | ||
9 | 31 | #include <QGuiApplication> | 32 | #include <QGuiApplication> |
10 | 32 | #include <private/qguiapplication_p.h> | 33 | #include <private/qguiapplication_p.h> |
11 | 33 | #include <qpa/qplatformnativeinterface.h> | 34 | #include <qpa/qplatformnativeinterface.h> |
12 | @@ -77,8 +78,12 @@ | |||
13 | 77 | , mClipboard(new UbuntuClipboard) | 78 | , mClipboard(new UbuntuClipboard) |
14 | 78 | , mScaleFactor(1.0) | 79 | , mScaleFactor(1.0) |
15 | 79 | { | 80 | { |
18 | 80 | setupOptions(); | 81 | { |
19 | 81 | setupDescription(); | 82 | QStringList args = QCoreApplication::arguments(); |
20 | 83 | setupOptions(args); | ||
21 | 84 | QByteArray sessionName = generateSessionName(args); | ||
22 | 85 | setupDescription(sessionName); | ||
23 | 86 | } | ||
24 | 82 | 87 | ||
25 | 83 | // Create new application instance | 88 | // Create new application instance |
26 | 84 | mInstance = u_application_instance_new_from_description_with_options(mDesc, mOptions); | 89 | mInstance = u_application_instance_new_from_description_with_options(mDesc, mOptions); |
27 | @@ -161,9 +166,8 @@ | |||
28 | 161 | return mServices; | 166 | return mServices; |
29 | 162 | } | 167 | } |
30 | 163 | 168 | ||
32 | 164 | void UbuntuClientIntegration::setupOptions() | 169 | void UbuntuClientIntegration::setupOptions(QStringList &args) |
33 | 165 | { | 170 | { |
34 | 166 | QStringList args = QCoreApplication::arguments(); | ||
35 | 167 | int argc = args.size() + 1; | 171 | int argc = args.size() + 1; |
36 | 168 | char **argv = new char*[argc]; | 172 | char **argv = new char*[argc]; |
37 | 169 | for (int i = 0; i < argc - 1; i++) | 173 | for (int i = 0; i < argc - 1; i++) |
38 | @@ -177,10 +181,11 @@ | |||
39 | 177 | delete [] argv; | 181 | delete [] argv; |
40 | 178 | } | 182 | } |
41 | 179 | 183 | ||
43 | 180 | void UbuntuClientIntegration::setupDescription() | 184 | void UbuntuClientIntegration::setupDescription(QByteArray &sessionName) |
44 | 181 | { | 185 | { |
45 | 182 | mDesc = u_application_description_new(); | 186 | mDesc = u_application_description_new(); |
47 | 183 | UApplicationId* id = u_application_id_new_from_stringn("QtUbuntu", 8); | 187 | |
48 | 188 | UApplicationId* id = u_application_id_new_from_stringn(sessionName.data(), sessionName.count()); | ||
49 | 184 | u_application_description_set_application_id(mDesc, id); | 189 | u_application_description_set_application_id(mDesc, id); |
50 | 185 | 190 | ||
51 | 186 | UApplicationLifecycleDelegate* delegate = u_application_lifecycle_delegate_new(); | 191 | UApplicationLifecycleDelegate* delegate = u_application_lifecycle_delegate_new(); |
52 | @@ -190,6 +195,35 @@ | |||
53 | 190 | u_application_description_set_application_lifecycle_delegate(mDesc, delegate); | 195 | u_application_description_set_application_lifecycle_delegate(mDesc, delegate); |
54 | 191 | } | 196 | } |
55 | 192 | 197 | ||
56 | 198 | QByteArray UbuntuClientIntegration::generateSessionName(QStringList &args) | ||
57 | 199 | { | ||
58 | 200 | // Try to come up with some meaningful session name to uniquely identify this session, | ||
59 | 201 | // helping with shell debugging | ||
60 | 202 | |||
61 | 203 | if (args.count() == 0) { | ||
62 | 204 | return QByteArray("QtUbuntu"); | ||
63 | 205 | } if (args[0].contains("qmlscene")) { | ||
64 | 206 | return generateSessionNameFromQmlFile(args); | ||
65 | 207 | } else { | ||
66 | 208 | // use the executable name | ||
67 | 209 | QFileInfo fileInfo(args[0]); | ||
68 | 210 | return fileInfo.fileName().toLocal8Bit(); | ||
69 | 211 | } | ||
70 | 212 | } | ||
71 | 213 | |||
72 | 214 | QByteArray UbuntuClientIntegration::generateSessionNameFromQmlFile(QStringList &args) | ||
73 | 215 | { | ||
74 | 216 | Q_FOREACH (QString arg, args) { | ||
75 | 217 | if (arg.endsWith(".qml")) { | ||
76 | 218 | QFileInfo fileInfo(arg); | ||
77 | 219 | return fileInfo.fileName().toLocal8Bit(); | ||
78 | 220 | } | ||
79 | 221 | } | ||
80 | 222 | |||
81 | 223 | // give up | ||
82 | 224 | return "qmlscene"; | ||
83 | 225 | } | ||
84 | 226 | |||
85 | 193 | QPlatformWindow* UbuntuClientIntegration::createPlatformWindow(QWindow* window) const | 227 | QPlatformWindow* UbuntuClientIntegration::createPlatformWindow(QWindow* window) const |
86 | 194 | { | 228 | { |
87 | 195 | return const_cast<UbuntuClientIntegration*>(this)->createPlatformWindow(window); | 229 | return const_cast<UbuntuClientIntegration*>(this)->createPlatformWindow(window); |
88 | 196 | 230 | ||
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 | 76 | void destroyScreen(UbuntuScreen *screen); | 76 | void destroyScreen(UbuntuScreen *screen); |
94 | 77 | 77 | ||
95 | 78 | private: | 78 | private: |
98 | 79 | void setupOptions(); | 79 | void setupOptions(QStringList &args); |
99 | 80 | void setupDescription(); | 80 | void setupDescription(QByteArray &sessionName); |
100 | 81 | static QByteArray generateSessionName(QStringList &args); | ||
101 | 82 | static QByteArray generateSessionNameFromQmlFile(QStringList &args); | ||
102 | 81 | 83 | ||
103 | 82 | UbuntuNativeInterface* mNativeInterface; | 84 | UbuntuNativeInterface* mNativeInterface; |
104 | 83 | QPlatformFontDatabase* mFontDb; | 85 | QPlatformFontDatabase* mFontDb; |
PASSED: Continuous integration, rev:317 /unity8- jenkins. ubuntu. com/job/ lp-qtubuntu- ci/63/ /unity8- jenkins. ubuntu. com/job/ build/1759 /unity8- jenkins. ubuntu. com/job/ build-0- fetch/1785 /unity8- jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= vivid+overlay/ 1732 /unity8- jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= xenial+ overlay/ 1732 /unity8- jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= yakkety/ 1732 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 1725 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 1725/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 1725 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 1725/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 1725 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 1725/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 1725 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 1725/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1725 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1725/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 1725 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 1725/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 1725 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 1725/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1725 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1725/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= yakkety/ 1725 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= yakkety/ 1725/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /unity8- jenkins. ubuntu. com/job/ lp-qtubuntu- ci/63/rebuild
https:/