From 773c53fdabb7d95fc9ab7ca0ee4a933b17d17426 Mon Sep 17 00:00:00 2001 From: Daniel d'Andrada Date: Thu, 1 Mar 2012 17:49:58 -0300 Subject: Fixes infinite loop in GestureEngine. 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. Fixes LP: #942625 (bzr r2044.2.1) --- plugins/unityshell/src/GestureEngine.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/unityshell/src/GestureEngine.cpp b/plugins/unityshell/src/GestureEngine.cpp index 96110111f..5a72843cb 100644 --- a/plugins/unityshell/src/GestureEngine.cpp +++ b/plugins/unityshell/src/GestureEngine.cpp @@ -85,13 +85,18 @@ GestureEngine::FindCompWindow(Window window) Window parent, root; Window* children = NULL; unsigned int nchildren; + Status status; - XQueryTree(_screen->dpy(), window, &root, &parent, &children, &nchildren); + status = XQueryTree(_screen->dpy(), window, &root, &parent, &children, &nchildren); + if (status == 0) + break; if (children) XFree(children); - if (parent == root) + // parent will be zero when the window passed to this method is already the + // root one. + if (parent == root || parent == 0) break; window = parent; @@ -215,7 +220,7 @@ GestureEngine::OnRotateFinish(GeisAdapter::GeisRotateData* data) void GestureEngine::OnTouchStart(GeisAdapter::GeisTouchData* data) { - if (data->touches == 3) + if (data->touches == 3 && data->window != 0) { CompWindow* result = FindCompWindow(data->window); -- cgit v1.2.3