Fixed various incorrect uses of the erase() method of several STL containers I introduced before. Thanks to Stefano for the hint!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21332 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-06-05 17:45:02 +00:00
parent 2f03d0e0ed
commit 618b37dc46
4 changed files with 24 additions and 22 deletions

View File

@ -690,7 +690,7 @@ ObserverList::_ValidateHandlers(uint32 what)
}
Add(target, what);
handlers.erase(iterator);
iterator = handlers.erase(iterator);
}
}
@ -707,7 +707,7 @@ ObserverList::_SendNotices(uint32 what, BMessage* message)
while (iterator != messengers.end()) {
if (!(*iterator).IsValid()) {
messengers.erase(iterator);
iterator = messengers.erase(iterator);
continue;
}
@ -793,10 +793,10 @@ ObserverList::Remove(const BHandler *handler, uint32 what)
vector<const BHandler*> &handlers = fHandlerMap[what];
vector<const BHandler*>::iterator iter;
iter = find(handlers.begin(), handlers.end(), handler);
if (iter != handlers.end()) {
handlers.erase(iter);
vector<const BHandler*>::iterator iterator = find(handlers.begin(),
handlers.end(), handler);
if (iterator != handlers.end()) {
handlers.erase(iterator);
if (handlers.empty())
fHandlerMap.erase(what);
@ -812,10 +812,10 @@ ObserverList::Remove(const BMessenger &messenger, uint32 what)
{
vector<BMessenger> &messengers = fMessengerMap[what];
vector<BMessenger>::iterator iter;
iter = find(messengers.begin(), messengers.end(), messenger);
if (iter != messengers.end()) {
messengers.erase(iter);
vector<BMessenger>::iterator iterator = find(messengers.begin(),
messengers.end(), messenger);
if (iterator != messengers.end()) {
messengers.erase(iterator);
if (messengers.empty())
fMessengerMap.erase(what);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2001-2005, Haiku.
* Copyright 2001-2007, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -132,7 +132,7 @@ RegistrarThreadManager::CleanupThreads()
} else {
OUT("WARNING: RegistrarThreadManager::CleanupThreads(): NULL mime_update_thread_shared_data "
"pointer found in and removed from RegistrarThreadManager::fThreads list\n");
i = fThreads.erase(i);
fThreads.erase(i);
}
i = next;
@ -168,7 +168,7 @@ RegistrarThreadManager::ShutdownThreads()
} else {
OUT("WARNING: RegistrarThreadManager::ShutdownThreads(): NULL mime_update_thread_shared_data "
"pointer found in and removed from RegistrarThreadManager::fThreads list\n");
i = fThreads.erase(i);
fThreads.erase(i);
}
i = next;

View File

@ -813,11 +813,11 @@ BPathMonitor::StopWatching(BMessenger target)
return B_BAD_VALUE;
struct watcher* watcher = iterator->second;
HandlerMap::iterator i = watcher->handlers.begin();
for (; i != watcher->handlers.end(); i++) {
while (!watcher->handlers.empty()) {
HandlerMap::iterator i = watcher->handlers.begin();
PathHandler* handler = i->second;
watcher->handlers.erase(i);
if (handler->LockLooper())
handler->Quit();
}

View File

@ -838,14 +838,12 @@ BTranslatorRoster::Private::_CompareSupport(const void* _a, const void* _b)
void
BTranslatorRoster::Private::_RescanChanged()
{
EntryRefSet::iterator iterator = fRescanEntries.begin();
while (iterator != fRescanEntries.end()) {
while (!fRescanEntries.empty()) {
EntryRefSet::iterator iterator = fRescanEntries.begin();
int32 count;
CreateTranslators(*iterator, count);
fRescanEntries.erase(iterator);
iterator++;
}
}
@ -1002,7 +1000,8 @@ BTranslatorRoster::Private::_IsKnownDirectory(const node_ref& nodeRef) const
void
BTranslatorRoster::Private::_RemoveTranslators(const node_ref* nodeRef, const entry_ref* ref)
BTranslatorRoster::Private::_RemoveTranslators(const node_ref* nodeRef,
const entry_ref* ref)
{
if (ref == NULL && nodeRef == NULL)
return;
@ -1012,6 +1011,9 @@ BTranslatorRoster::Private::_RemoveTranslators(const node_ref* nodeRef, const en
image_id image = -1;
while (iterator != fTranslators.end()) {
TranslatorMap::iterator next = iterator;
next++;
const translator_item& item = iterator->second;
if ((ref != NULL && item.ref == *ref)
|| (nodeRef != NULL && item.ref.device == nodeRef->device
@ -1026,7 +1028,7 @@ BTranslatorRoster::Private::_RemoveTranslators(const node_ref* nodeRef, const en
fTranslators.erase(iterator);
}
iterator++;
iterator = next;
}
// Unload image from the removed translator