Mir

Merge lp:~kdub/mir/fix-1483779-silo0 into lp:~mir-team/mir/silo0

Proposed by Kevin DuBois
Status: Merged
Merged at revision: 2703
Proposed branch: lp:~kdub/mir/fix-1483779-silo0
Merge into: lp:~mir-team/mir/silo0
Diff against target: 52 lines (+18/-2)
2 files modified
src/server/graphics/software_cursor.cpp (+3/-2)
tests/unit-tests/graphics/test_software_cursor.cpp (+15/-0)
To merge this branch: bzr merge lp:~kdub/mir/fix-1483779-silo0
Reviewer Review Type Date Requested Status
Daniel van Vugt Abstain
Mir development team Pending
Review via email: mp+267675@code.launchpad.net

Commit message

software cursor: avoid a situation where we would double-remove an input visual that had been hidden. Default behavior of ms::SurfaceStack on a double removal is to throw.

fixes: lp: #1483779

Description of the change

software cursor: avoid a situation where we would double-remove an input visual that had been hidden. Default behavior of ms::SurfaceStack on a double removal is to throw.

fixes: lp: #1483779

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

This fix is not present on trunk (lp:mir). Don't we want to propose it there first? Or is it not a bug at all on trunk?

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Never mind. I just found your other MP and linked it to the bug.

review: Abstain

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/graphics/software_cursor.cpp'
2--- src/server/graphics/software_cursor.cpp 2015-06-17 05:20:42 +0000
3+++ src/server/graphics/software_cursor.cpp 2015-08-11 15:00:41 +0000
4@@ -136,7 +136,7 @@
5 {
6 std::shared_ptr<detail::CursorRenderable> new_renderable;
7 std::shared_ptr<detail::CursorRenderable> old_renderable;
8-
9+ bool old_visibility = false;
10 // Do a lock dance to make this function threadsafe,
11 // while avoiding calling scene methods under lock
12 {
13@@ -145,6 +145,7 @@
14 if (renderable)
15 position = renderable->screen_position().top_left;
16 new_renderable = create_renderable_for(cursor_image, position);
17+ old_visibility = visible;
18 visible = true;
19 }
20
21@@ -160,7 +161,7 @@
22 hotspot = cursor_image.hotspot();
23 }
24
25- if (old_renderable)
26+ if (old_renderable && old_visibility)
27 scene->remove_input_visualization(old_renderable);
28 }
29
30
31=== modified file 'tests/unit-tests/graphics/test_software_cursor.cpp'
32--- tests/unit-tests/graphics/test_software_cursor.cpp 2015-06-17 05:20:42 +0000
33+++ tests/unit-tests/graphics/test_software_cursor.cpp 2015-08-11 15:00:41 +0000
34@@ -313,3 +313,18 @@
35 cursor.show(another_stub_cursor_image);
36 cursor.show(stub_cursor_image);
37 }
38+
39+//lp: 1483779
40+TEST_F(SoftwareCursor, doesnt_try_to_remove_after_hiding)
41+{
42+ using namespace testing;
43+
44+ EXPECT_CALL(mock_input_scene, add_input_visualization(_))
45+ .Times(2);
46+ EXPECT_CALL(mock_input_scene, remove_input_visualization(_))
47+ .Times(1);
48+ cursor.show(stub_cursor_image);
49+ cursor.hide(); //should remove here
50+ cursor.show(stub_cursor_image); //should add, but not remove a second time
51+ Mock::VerifyAndClearExpectations(&mock_input_scene);
52+}

Subscribers

People subscribed via source and target branches