Merge lp:~smspillaz/unity/unity.maybe_fix_825040 into lp:unity

Proposed by Sam Spilsbury
Status: Merged
Merged at revision: 1381
Proposed branch: lp:~smspillaz/unity/unity.maybe_fix_825040
Merge into: lp:unity
Diff against target: 48 lines (+19/-6)
1 file modified
plugins/unityshell/src/unityshell.cpp (+19/-6)
To merge this branch: bzr merge lp:~smspillaz/unity/unity.maybe_fix_825040
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+71895@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

Looks good, please add another indentation space to the new code :)

review: Approve
Revision history for this message
Andrea Cimitan (cimi) wrote :

line "* it is valid, then it++ returns the old" starts with a tab indentation, instead spaces :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/unityshell.cpp'
2--- plugins/unityshell/src/unityshell.cpp 2011-08-16 23:04:40 +0000
3+++ plugins/unityshell/src/unityshell.cpp 2011-08-17 16:13:32 +0000
4@@ -996,25 +996,38 @@
5 const CompWindowList& UnityScreen::getWindowPaintList()
6 {
7 CompWindowList& pl = _withRemovedNuxWindows = cScreen->getWindowPaintList();
8- CompWindowList::iterator it = pl.end();
9- CompWindowList::iterator begin = pl.begin();
10+ CompWindowList::reverse_iterator it = pl.rbegin();
11+ CompWindowList::reverse_iterator end = pl.rend();
12 std::vector<Window> const& xwns = nux::XInputWindow::NativeHandleList();
13
14 unsigned int size = xwns.size();
15
16- while (it != begin)
17+ while (it != end)
18 {
19- --it;
20-
21+ bool erased = false;
22 auto id = (*it)->id();
23 for (unsigned int i = 0; i < size; ++i)
24 {
25 if (xwns[i] == id)
26 {
27- it = pl.erase(it);
28+ /* Increment the reverse_iterator to ensure
29+ * it is valid, then it++ returns the old
30+ * position */
31+ CompWindowList::reverse_iterator oit = it++;
32+ /* Get the base and offset by -1 since
33+ * &*(reverse_iterator(i)) == &*(i - 1)) */
34+ CompWindowList::iterator eit = --(oit.base ());
35+
36+ erased = true;
37+
38+ /* Remove that from the list */
39+ pl.erase(eit);
40 break;
41 }
42 }
43+
44+ if (!erased)
45+ it++;
46 }
47
48 return pl;