From f72ed717b41c14c0c13f71d5490c58867fcff421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 7 Aug 2008 21:42:02 +0000 Subject: [PATCH] The previous loop to remove all the BHandlers in the destructor was really quite inefficient. And while it did check if the handler was not NULL, it would have resulted in an endless loop if it was. I think we can safely assume we have no NULL BHandlers in that list though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26870 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/app/Looper.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/kits/app/Looper.cpp b/src/kits/app/Looper.cpp index ab4c7da530..ea1baf5e8f 100644 --- a/src/kits/app/Looper.cpp +++ b/src/kits/app/Looper.cpp @@ -153,12 +153,13 @@ BLooper::~BLooper() RemoveHandler(this); // Remove all the "child" handlers - BHandler* child; - while (CountHandlers()) { - child = HandlerAt(0); - if (child) - RemoveHandler(child); + int32 count = fHandlers.CountItems(); + for (int32 i = 0; i < count; i++) { + BHandler* handler = (BHandler*)fHandlers.ItemAtFast(i); + handler->SetNextHandler(NULL); + handler->SetLooper(NULL); } + fHandlers.MakeEmpty(); Unlock(); gLooperList.RemoveLooper(this);