Merge lp:~alan-griffiths/miral/fix-1575211 into lp:miral

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: 162
Merged at revision: 162
Proposed branch: lp:~alan-griffiths/miral/fix-1575211
Merge into: lp:miral
Diff against target: 38 lines (+6/-6)
1 file modified
miral-shell/titlebar/canonical_window_management_policy_data.cpp (+6/-6)
To merge this branch: bzr merge lp:~alan-griffiths/miral/fix-1575211
Reviewer Review Type Date Requested Status
Cemil Azizoglu (community) Approve
Review via email: mp+293094@code.launchpad.net

Commit message

examples: fix racy code that failed to ensure buffers are posted exactly once

Description of the change

examples: fix racy code that failed to ensure buffers are posted exactly once

To post a comment you must log in.
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

yep

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

same fix has landed in Mir

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'miral-shell/titlebar/canonical_window_management_policy_data.cpp'
2--- miral-shell/titlebar/canonical_window_management_policy_data.cpp 2016-04-16 23:13:59 +0000
3+++ miral-shell/titlebar/canonical_window_management_policy_data.cpp 2016-04-27 12:03:25 +0000
4@@ -43,29 +43,29 @@
5 SwappingPainter(std::shared_ptr<mir::frontend::BufferStream> const& buffer_stream) :
6 buffer_stream{buffer_stream}, buffer{nullptr}
7 {
8- swap_buffers();
9+ swap_buffers(nullptr);
10 }
11
12- void swap_buffers()
13+ void swap_buffers(mir::graphics::Buffer* buf)
14 {
15 auto const callback = [this](mir::graphics::Buffer* new_buffer)
16 {
17- buffer.store(new_buffer);
18+ buffer.store(new_buffer);
19 };
20
21- buffer_stream->swap_buffers(buffer, callback);
22+ buffer_stream->swap_buffers(buf, callback);
23 }
24
25 void paint(int intensity) override
26 {
27- if (auto const buf = buffer.load())
28+ if (auto const buf = buffer.exchange(nullptr))
29 {
30 auto const format = buffer_stream->pixel_format();
31 auto const sz = buf->size().height.as_int() *
32 buf->size().width.as_int() * MIR_BYTES_PER_PIXEL(format);
33 std::vector<unsigned char> pixels(sz, intensity);
34 buf->write(pixels.data(), sz);
35- swap_buffers();
36+ swap_buffers(buf);
37 }
38 }
39

Subscribers

People subscribed via source and target branches