From 675ef17d92207e910da61befe6bfa36cd66fbdfa Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Sat, 14 May 2011 02:22:37 +0200 Subject: [PATCH] Bug fix: don't loop endlessly when getParentFloater returns it's argument. It has happened to me that this hung the viewer. The cause is that when you call parent->getParentFloater(child), then getParentFloater which starts like this: LLFloater* LLFloaterView::getParentFloater(LLView* viewp) { LLView* parentp = viewp->getParent(); starts with parentp == this. And the following logic causes it to return 'viewp'! I'm pretty sure that getParentFloater's whole design is wrong, but I don't see another way to avoid this problem then with this hack, except by making changes that do a lot more and are a risk with regard breaking code elsewhere. --- indra/llui/llfloater.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 2d72026a2..0ab07c5e4 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1356,14 +1356,20 @@ LLFloater* LLFloater::getClosableFloaterFromFocus() // The focused floater may not be closable, // Find and close a parental floater that is closeable, if any. + LLFloater* previous_floater = NULL; // Guard against endless loop, because getParentFloater(x) can return x! for(LLFloater* floater_to_close = focused_floater; NULL != floater_to_close; floater_to_close = gFloaterView->getParentFloater(floater_to_close)) { + if(floater_to_close == previous_floater) + { + break; + } if(floater_to_close->isCloseable()) { return floater_to_close; } + previous_floater = floater_to_close; } return NULL;