Merge lp:~dandrader/unity/lp942625 into lp:unity

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2047
Proposed branch: lp:~dandrader/unity/lp942625
Merge into: lp:unity
Diff against target: 32 lines (+8/-3)
1 file modified
plugins/unityshell/src/GestureEngine.cpp (+8/-3)
To merge this branch: bzr merge lp:~dandrader/unity/lp942625
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Review via email: mp+95457@code.launchpad.net

This proposal supersedes a proposal from 2012-03-01.

Description of the change

Fixes lp:942625

GestureEngine::FindCompWindow() would enter in an infinite loop if the window passed to it is the root window since its break condition (parent == root) would never be reached as parent would be zero.

Also includes some other safeguards around the same issue.

UNBLOCK

To post a comment you must log in.
Revision history for this message
Andrea Cimitan (cimi) wrote : Posted in a previous version of this proposal

8 + Status status;
9
10 XQueryTree(_screen->dpy(), window, &root, &parent, &children, &nchildren);
11 + if (status == 0)
12 + break;

Did you forget to initialize 'status'?

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

> 8 + Status status;
> 9
> 10 XQueryTree(_screen->dpy(), window, &root, &parent, &children,
> &nchildren);
> 11 + if (status == 0)
> 12 + break;
>
> Did you forget to initialize 'status'?

Yes indeed.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Patch updated.

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

Fixes the bug for me

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/GestureEngine.cpp'
2--- plugins/unityshell/src/GestureEngine.cpp 2012-02-04 05:28:23 +0000
3+++ plugins/unityshell/src/GestureEngine.cpp 2012-03-01 20:53:28 +0000
4@@ -85,13 +85,18 @@
5 Window parent, root;
6 Window* children = NULL;
7 unsigned int nchildren;
8+ Status status;
9
10- XQueryTree(_screen->dpy(), window, &root, &parent, &children, &nchildren);
11+ status = XQueryTree(_screen->dpy(), window, &root, &parent, &children, &nchildren);
12+ if (status == 0)
13+ break;
14
15 if (children)
16 XFree(children);
17
18- if (parent == root)
19+ // parent will be zero when the window passed to this method is already the
20+ // root one.
21+ if (parent == root || parent == 0)
22 break;
23
24 window = parent;
25@@ -215,7 +220,7 @@
26 void
27 GestureEngine::OnTouchStart(GeisAdapter::GeisTouchData* data)
28 {
29- if (data->touches == 3)
30+ if (data->touches == 3 && data->window != 0)
31 {
32 CompWindow* result = FindCompWindow(data->window);
33