Merge lp:~ted/ubuntu-app-launch/primary-pid-no-app into lp:ubuntu-app-launch/16.10

Proposed by Ted Gould
Status: Merged
Approved by: dobey
Approved revision: 246
Merged at revision: 246
Proposed branch: lp:~ted/ubuntu-app-launch/primary-pid-no-app
Merge into: lp:ubuntu-app-launch/16.10
Diff against target: 61 lines (+7/-5)
2 files modified
libubuntu-app-launch/ubuntu-app-launch.cpp (+5/-5)
tests/libual-test.cc (+2/-0)
To merge this branch: bzr merge lp:~ted/ubuntu-app-launch/primary-pid-no-app
Reviewer Review Type Date Requested Status
unity-api-1-bot continuous-integration Needs Fixing
dobey (community) Approve
Review via email: mp+303940@code.launchpad.net

Commit message

Use at() instead of operator[]() so that we get an exception on bounds checking

Description of the change

Didn't realize that vector's operator[]() doesn't do any bounds checking and it just crashes. Which is stupid, but supported by the documentation. Switching to use at() that does do bounds checking and throws an exception that we can catch as we'd expected.

To post a comment you must log in.
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Continuous integration, rev:246
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/69/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/487/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/493
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/398
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/398
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/398
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/328/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/328
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/328/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/328
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/328/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/328/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/328
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/328/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/328
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/328/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/328/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/328
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/328/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/328
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/328/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/69/rebuild

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libubuntu-app-launch/ubuntu-app-launch.cpp'
2--- libubuntu-app-launch/ubuntu-app-launch.cpp 2016-08-04 15:04:04 +0000
3+++ libubuntu-app-launch/ubuntu-app-launch.cpp 2016-08-25 14:25:42 +0000
4@@ -465,7 +465,7 @@
5 auto registry = ubuntu::app_launch::Registry::getDefault();
6 auto appId = ubuntu::app_launch::AppID::find(appid);
7 auto app = ubuntu::app_launch::Application::create(appId, registry);
8- app->instances()[0]->pause();
9+ app->instances().at(0)->pause();
10 return TRUE;
11 } catch (...) {
12 return FALSE;
13@@ -479,7 +479,7 @@
14 auto registry = ubuntu::app_launch::Registry::getDefault();
15 auto appId = ubuntu::app_launch::AppID::find(appid);
16 auto app = ubuntu::app_launch::Application::create(appId, registry);
17- app->instances()[0]->resume();
18+ app->instances().at(0)->resume();
19 return TRUE;
20 } catch (...) {
21 return FALSE;
22@@ -1211,7 +1211,7 @@
23 auto registry = std::make_shared<ubuntu::app_launch::Registry>();
24 auto appId = ubuntu::app_launch::AppID::find(appid);
25 auto app = ubuntu::app_launch::Application::create(appId, registry);
26- return app->instances()[0]->primaryPid();
27+ return app->instances().at(0)->primaryPid();
28 } catch (...) {
29 return 0;
30 }
31@@ -1227,7 +1227,7 @@
32 auto registry = std::make_shared<ubuntu::app_launch::Registry>();
33 auto appId = ubuntu::app_launch::AppID::find(appid);
34 auto app = ubuntu::app_launch::Application::create(appId, registry);
35- auto pids = app->instances()[0]->pids();
36+ auto pids = app->instances().at(0)->pids();
37
38 GList * retval = nullptr;
39 for (auto pid : pids) {
40@@ -1249,7 +1249,7 @@
41 auto appId = ubuntu::app_launch::AppID::find(appid);
42 auto app = ubuntu::app_launch::Application::create(appId, registry);
43
44- if (app->instances()[0]->hasPid(pid)) {
45+ if (app->instances().at(0)->hasPid(pid)) {
46 return TRUE;
47 } else {
48 return FALSE;
49
50=== modified file 'tests/libual-test.cc'
51--- tests/libual-test.cc 2016-08-17 13:17:08 +0000
52+++ tests/libual-test.cc 2016-08-25 14:25:42 +0000
53@@ -509,6 +509,8 @@
54 EXPECT_TRUE(g_variant_equal(calls->params, g_variant_new("(ss)", "freezer", "upstart/application-legacy-multiple-2342345")));
55 ASSERT_TRUE(dbus_test_dbus_mock_object_clear_method_calls(cgmock, cgobject, NULL));
56
57+ /* Check non running app */
58+ EXPECT_EQ(0, ubuntu_app_launch_get_primary_pid("chatter.robert-ancell_chatter_2"));
59 }
60
61 TEST_F(LibUAL, ApplicationId)

Subscribers

People subscribed via source and target branches