HaikuDepot: Fix usage of std::remove.
That's right kids, std::remove doesn't (and can't) actually remove things from containers! Instead you have to pass its results into container::erase in order to do anything at all. Fixes #17579, and in my testing at least, the strange crashes and heap corruptions.
This commit is contained in:
@@ -174,9 +174,7 @@ EditManager::AddListener(Listener* listener)
|
|||||||
void
|
void
|
||||||
EditManager::RemoveListener(Listener* listener)
|
EditManager::RemoveListener(Listener* listener)
|
||||||
{
|
{
|
||||||
fListeners.erase(std::remove(
|
fListeners.erase(std::remove(fListeners.begin(), fListeners.end(),
|
||||||
fListeners.begin(),
|
|
||||||
fListeners.end(),
|
|
||||||
listener), fListeners.end());
|
listener), fListeners.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1041,7 +1041,8 @@ PackageInfo::AddListener(const PackageInfoListenerRef& listener)
|
|||||||
void
|
void
|
||||||
PackageInfo::RemoveListener(const PackageInfoListenerRef& listener)
|
PackageInfo::RemoveListener(const PackageInfoListenerRef& listener)
|
||||||
{
|
{
|
||||||
std::remove(fListeners.begin(), fListeners.end(), listener);
|
fListeners.erase(std::remove(fListeners.begin(), fListeners.end(),
|
||||||
|
listener), fListeners.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -141,9 +141,9 @@ TextDocument::Replace(int32 textOffset, int32 length, TextDocumentRef document)
|
|||||||
{
|
{
|
||||||
int32 firstParagraph = 0;
|
int32 firstParagraph = 0;
|
||||||
int32 paragraphCount = 0;
|
int32 paragraphCount = 0;
|
||||||
|
|
||||||
// TODO: Call _NotifyTextChanging() before any change happened
|
// TODO: Call _NotifyTextChanging() before any change happened
|
||||||
|
|
||||||
status_t ret = _Remove(textOffset, length, firstParagraph, paragraphCount);
|
status_t ret = _Remove(textOffset, length, firstParagraph, paragraphCount);
|
||||||
if (ret != B_OK)
|
if (ret != B_OK)
|
||||||
return ret;
|
return ret;
|
||||||
@@ -443,7 +443,8 @@ TextDocument::AddListener(TextListenerRef listener)
|
|||||||
bool
|
bool
|
||||||
TextDocument::RemoveListener(TextListenerRef listener)
|
TextDocument::RemoveListener(TextListenerRef listener)
|
||||||
{
|
{
|
||||||
std::remove(fTextListeners.begin(), fTextListeners.end(), listener);
|
fTextListeners.erase(std::remove(fTextListeners.begin(), fTextListeners.end(),
|
||||||
|
listener), fTextListeners.end());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user