Merge lp:~unity-api-team/hud/null-guard-itemstore into lp:hud/14.04

Proposed by Pete Woods
Status: Merged
Approved by: Charles Kerr
Approved revision: 384
Merged at revision: 383
Proposed branch: lp:~unity-api-team/hud/null-guard-itemstore
Merge into: lp:hud/14.04
Prerequisite: lp:~charlesk/hud/qtgactiongroup-cleanup
Diff against target: 59 lines (+31/-2)
2 files modified
service/ItemStore.cpp (+10/-2)
tests/unit/service/TestItemStore.cpp (+21/-0)
To merge this branch: bzr merge lp:~unity-api-team/hud/null-guard-itemstore
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Charles Kerr Pending
Review via email: mp+211893@code.launchpad.net

This proposal supersedes a proposal from 2014-03-18.

Commit message

Add null guards to ItemStore search

Description of the change

* Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
  * Yes
 * Did you build your software in a clean sbuild/pbuilder chroot or ppa?
  * Yes
 * Did you build your software in a clean sbuild/pbuilder armhf chroot or ppa?
  * Yes
 * Has your component "TestPlan” been executed successfully on emulator, N4?
  * Yes
 * Has a 5 minute exploratory testing run been executed on N4?
  * Yes
 * If you changed the packaging (debian), did you subscribe a core-dev to this MP?
  * N/A
 * If you changed the UI, did you subscribe the design-reviewers to this MP?
  * No change
 * What components might get impacted by your changes?
  * Unity7
  * Unity8
 * Have you requested review by the teams of these owning components?
  * Yes

Check List:
https://wiki.ubuntu.com/Process/Merges/Checklists/hud

Test Plan:
https://wiki.ubuntu.com/Process/Merges/TestPlan/hud

Silo:
<waiting for silo>

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote : Posted in a previous version of this proposal

LGTM.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'service/ItemStore.cpp'
2--- service/ItemStore.cpp 2014-02-28 13:51:34 +0000
3+++ service/ItemStore.cpp 2014-03-20 10:02:51 +0000
4@@ -166,8 +166,12 @@
5 QMap<unsigned int, DocumentID> tempResults;
6
7 for (auto it(m_items.constBegin()); it != m_items.constEnd(); ++it) {
8- tempResults.insertMulti(m_usageTracker->usage(m_applicationId,
9- convertToEntry(it.value(), it.value()->action())), it.key());
10+ const QAction* action = it.value()->action();
11+ if (action) {
12+ tempResults.insertMulti(
13+ m_usageTracker->usage(m_applicationId,
14+ convertToEntry(it.value(), action)), it.key());
15+ }
16 }
17
18 int maxResults = std::min(m_items.size(), 20);
19@@ -214,6 +218,10 @@
20 Item::Ptr item(m_items[id]);
21 const QAction *action(item->action());
22
23+ if (!action) {
24+ return;
25+ }
26+
27 QString commandName(convertActionText(action));
28
29 Result::HighlightList commandHighlights;
30
31=== modified file 'tests/unit/service/TestItemStore.cpp'
32--- tests/unit/service/TestItemStore.cpp 2014-02-28 12:47:38 +0000
33+++ tests/unit/service/TestItemStore.cpp 2014-03-20 10:02:51 +0000
34@@ -331,4 +331,25 @@
35 EXPECT_EQ("Can Cherry", search("Ban"));
36 }
37
38+TEST_F(TestItemStore, DeletedActions) {
39+ QMenu root;
40+
41+ QMenu file("&File");
42+ file.addAction("Apple");
43+ file.addAction("Banana");
44+ file.addAction("Can Cherry");
45+ root.addMenu(&file);
46+
47+ store->indexMenu(&root);
48+
49+ file.clear();
50+ root.clear();
51+
52+ // It should not crash! :)
53+ EXPECT_EQ("", search("flibble"));
54+
55+ // It should not crash! :)
56+ EXPECT_EQ("", search(""));
57+}
58+
59 } // namespace

Subscribers

People subscribed via source and target branches