Author: anevilyak Date: 2011-06-18 05:22:31 +0200 (Sat, 18 Jun 2011) New Revision: 42229 Changeset: https://dev.haiku-os.org/changeset/42229 Ticket: https://dev.haiku-os.org/ticket/7696 Modified: haiku/trunk/src/kits/tracker/PendingNodeMonitorCache.cpp Log: Remove the monitor item before calling FSNotification() on it. Otherwise, in some cases PoseView would call back into PoseCreatedOrMoved(), leading to an infinite recursion. Fixes #7696. Modified: haiku/trunk/src/kits/tracker/PendingNodeMonitorCache.cpp =================================================================== --- haiku/trunk/src/kits/tracker/PendingNodeMonitorCache.cpp 2011-06-18 01:52:29 UTC (rev 42228) +++ haiku/trunk/src/kits/tracker/PendingNodeMonitorCache.cpp 2011-06-18 03:22:31 UTC (rev 42229) @@ -53,13 +53,13 @@ return &fNodeMonitor; } -bool +bool PendingNodeMonitorEntry::Match(const node_ref *node) const { return fNode == *node; } -bool +bool PendingNodeMonitorEntry::TooOld(bigtime_t now) const { return now > fExpiresAfter; @@ -76,7 +76,7 @@ { } -void +void PendingNodeMonitorCache::Add(const BMessage *message) { #if xDEBUG @@ -91,39 +91,38 @@ fList.AddItem(new PendingNodeMonitorEntry(&node, message)); } -void +void PendingNodeMonitorCache::RemoveEntries(const node_ref *nodeRef) { int32 count = fList.CountItems(); - for (int32 index = count - 1; index >= 0; index--) + for (int32 index = count - 1; index >= 0; index--) if (fList.ItemAt(index)->Match(nodeRef)) delete fList.RemoveItemAt(index); } -void +void PendingNodeMonitorCache::RemoveOldEntries() { bigtime_t now = system_time(); int32 count = fList.CountItems(); - for (int32 index = count - 1; index >= 0; index--) + for (int32 index = count - 1; index >= 0; index--) if (fList.ItemAt(index)->TooOld(now)) { PRINT(("removing old entry from pending node monitor cache\n")); delete fList.RemoveItemAt(index); } } -void +void PendingNodeMonitorCache::PoseCreatedOrMoved(BPoseView *poseView, const BPose *pose) { bigtime_t now = system_time(); - int32 count = fList.CountItems(); - for (int32 index = 0; index < count;) { + for (int32 index = 0; index < fList.CountItems();) { PendingNodeMonitorEntry *item = fList.ItemAt(index); if (item->TooOld(now)) { PRINT(("removing old entry from pending node monitor cache\n")); delete fList.RemoveItemAt(index); - count--; } else if (item->Match(pose->TargetModel()->NodeRef())) { + fList.RemoveItemAt(index); #if DEBUG PRINT(("reapplying node monitor for model:\n")); pose->TargetModel()->PrintToStream(); @@ -132,8 +131,7 @@ #endif poseView->FSNotification(item->NodeMonitor()); ASSERT(result); - delete fList.RemoveItemAt(index); - count--; + delete item; } else index++; }