Merge lp:~mzanetti/unity-mir/fix-appid-parsing into lp:unity-mir

Proposed by Michael Zanetti
Status: Merged
Approved by: Gerry Boland
Approved revision: 115
Merged at revision: 115
Proposed branch: lp:~mzanetti/unity-mir/fix-appid-parsing
Merge into: lp:unity-mir
Diff against target: 76 lines (+25/-10)
3 files modified
src/modules/Unity/Application/application_manager.cpp (+9/-1)
src/modules/Unity/Application/desktopfilereader.cpp (+13/-8)
src/modules/Unity/Application/desktopfilereader.h (+3/-1)
To merge this branch: bzr merge lp:~mzanetti/unity-mir/fix-appid-parsing
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+190419@code.launchpad.net

Commit message

fix loading of appId when an app is launched with --desktop_file_hint

Description of the change

The applicationmanager uses the appId to identify applications. Right now there is a bug that causes the appId to be set to the full .desktop file path instead of only the appId. This causes focusing issues for manually launched (via cmdline) apps and also breaks app_lifecycle AP tests on Mir.

The issue is that the DesktopFileReader can be called with both, an appid and a file path and correctly finds the according desktop file, but in case it's called with a full file path, it assigns that one to the appId instead of exctracting the appId from it.

This merge splits the DesktopFileReader's ctor into 2 in order to avoid such confusion. When using a QString, it expects an appId. In order to load a .desktop file specified by a filename, the second ctor with QFileInfo is to be used.

This merge obviously also makes use of the QFileInfo ctor in the case when we launch an app with --desktop_file_hint, while keeping on using the appId version for all other cases.

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

add support for giving only the appId with --desktop_file_hint

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/modules/Unity/Application/application_manager.cpp'
2--- src/modules/Unity/Application/application_manager.cpp 2013-10-10 19:48:57 +0000
3+++ src/modules/Unity/Application/application_manager.cpp 2013-10-11 09:37:27 +0000
4@@ -386,7 +386,15 @@
5 QString desktopFileName = regExpMatch.captured(1);
6 DLOG("Process supplied desktop_file_hint, loading '%s'", desktopFileName.toLatin1().data());
7
8- DesktopFileReader* desktopData = new DesktopFileReader(desktopFileName);
9+ // FIXME: right now we support --desktop_file_hint=appId for historical reasons. So let's try that in
10+ // case we didn't get an existing .desktop file path
11+ DesktopFileReader* desktopData;
12+ if (QFileInfo(desktopFileName).exists()) {
13+ desktopData = new DesktopFileReader(QFileInfo(desktopFileName));
14+ } else {
15+ desktopData = new DesktopFileReader(desktopFileName);
16+ }
17+
18 if (!desktopData->loaded()) {
19 delete desktopData;
20 LOG("ApplicationManager REJECTED connection from app with pid %lld as desktop_file_hint file not found", pid);
21
22=== modified file 'src/modules/Unity/Application/desktopfilereader.cpp'
23--- src/modules/Unity/Application/desktopfilereader.cpp 2013-09-19 20:37:30 +0000
24+++ src/modules/Unity/Application/desktopfilereader.cpp 2013-10-11 09:37:27 +0000
25@@ -29,20 +29,25 @@
26 #define ARRAY_SIZE(a) \
27 ((sizeof(a) / sizeof(*(a))) / static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
28
29-DesktopFileReader::DesktopFileReader(QString appId)
30+DesktopFileReader::DesktopFileReader(const QString &appId)
31 : appId_(appId)
32 , entries_(DesktopFileReader::kNumberOfEntries, "")
33 {
34 DLOG("DesktopFileReader::DesktopFileReader (this=%p, appId='%s')", this, appId.toLatin1().data());
35 DASSERT(appId != NULL);
36
37- QFileInfo file(appId);
38- if(file.exists()) {
39- file_ = appId;
40- } else {
41- file_ = findDesktopFile(appId);
42- }
43-
44+ file_ = findDesktopFile(appId);
45+ loaded_ = loadDesktopFile(file_);
46+}
47+
48+DesktopFileReader::DesktopFileReader(const QFileInfo &desktopFile)
49+ : entries_(DesktopFileReader::kNumberOfEntries, "")
50+{
51+ DLOG("DesktopFileReader::DesktopFileReader (this=%p, desktopFile='%s')", this, desktopFile.absoluteFilePath().toLatin1().data());
52+ DASSERT(desktopFile.exists());
53+
54+ appId_ = desktopFile.completeBaseName();
55+ file_ = desktopFile.absoluteFilePath();
56 loaded_ = loadDesktopFile(file_);
57 }
58
59
60=== modified file 'src/modules/Unity/Application/desktopfilereader.h'
61--- src/modules/Unity/Application/desktopfilereader.h 2013-09-12 17:27:47 +0000
62+++ src/modules/Unity/Application/desktopfilereader.h 2013-10-11 09:37:27 +0000
63@@ -19,10 +19,12 @@
64
65 #include <QString>
66 #include <QVector>
67+#include <QFileInfo>
68
69 class DesktopFileReader {
70 public:
71- DesktopFileReader(QString desktopFile);
72+ DesktopFileReader(const QString &appId);
73+ DesktopFileReader(const QFileInfo &desktopFile);
74 ~DesktopFileReader();
75
76 QString file() const { return file_; }

Subscribers

People subscribed via source and target branches