Mir

Merge lp:~mir-team/mir/fix-1438160 into lp:mir

Proposed by Chris Halse Rogers
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 2451
Proposed branch: lp:~mir-team/mir/fix-1438160
Merge into: lp:mir
Diff against target: 60 lines (+41/-1)
2 files modified
src/client/input/android/android_input_receiver.cpp (+1/-1)
tests/acceptance-tests/test_client_library.cpp (+40/-0)
To merge this branch: bzr merge lp:~mir-team/mir/fix-1438160
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Kevin DuBois (community) Approve
Daniel van Vugt Approve
Review via email: mp+254863@code.launchpad.net

Commit message

Don't close() the surface input fd in ~InputDispatcher()

Fixes: https://bugs.launchpad.net/mir/+bug/1438160

Description of the change

Don't close() the surface input fd in ~InputDispatcher().

IntOwnedFd is one of the downsides of us using std::shared_ptr to do mir::Fd. I might at some point see how things look if mir::Fd copies via dup() instead...

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Works for me (manually tested too).

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

lgtm. shared_ptr<> seemed better than dup when mir::Fd came around, mostly for the sake of less communication with the kernel.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

OK as a fix. But ideally a test actually passes or fails (not passes or crashes).

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
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 'src/client/input/android/android_input_receiver.cpp'
2--- src/client/input/android/android_input_receiver.cpp 2015-03-31 02:35:42 +0000
3+++ src/client/input/android/android_input_receiver.cpp 2015-04-01 23:12:24 +0000
4@@ -91,7 +91,7 @@
5 process_and_maybe_send_event();
6 });
7
8- dispatcher.add_watch(mir::Fd{input_channel->getFd()},
9+ dispatcher.add_watch(mir::Fd{mir::IntOwnedFd{input_channel->getFd()}},
10 [this]() { process_and_maybe_send_event(); });
11 }
12
13
14=== modified file 'tests/acceptance-tests/test_client_library.cpp'
15--- tests/acceptance-tests/test_client_library.cpp 2015-03-31 02:35:42 +0000
16+++ tests/acceptance-tests/test_client_library.cpp 2015-04-01 23:12:24 +0000
17@@ -837,3 +837,43 @@
18 mir_surface_release_sync(surface);
19 mir_connection_release(connection);
20 }
21+
22+namespace
23+{
24+void dummy_event_handler_one(MirSurface*, MirEvent const*, void*)
25+{
26+}
27+
28+void dummy_event_handler_two(MirSurface*, MirEvent const*, void*)
29+{
30+}
31+}
32+
33+/*
34+ * Regression test for LP: 1438160
35+ */
36+TEST_F(ClientLibrary, can_change_event_delegate)
37+{
38+ using namespace testing;
39+
40+ auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
41+
42+ auto surface_spec = mir_connection_create_spec_for_normal_surface(connection,
43+ 800, 600,
44+ mir_pixel_format_argb_8888);
45+ auto surface = mir_surface_create_sync(surface_spec);
46+ mir_surface_spec_release(surface_spec);
47+
48+ ASSERT_THAT(surface, IsValid());
49+
50+ /* TODO: When provide-event-fd lands, change this into a better test that actually
51+ * tests that the correct event handler is called.
52+ *
53+ * Without manual dispatch, it's racy to try and test that.
54+ */
55+ mir_surface_set_event_handler(surface, &dummy_event_handler_one, nullptr);
56+ mir_surface_set_event_handler(surface, &dummy_event_handler_two, nullptr);
57+
58+ mir_surface_release_sync(surface);
59+ mir_connection_release(connection);
60+}

Subscribers

People subscribed via source and target branches