Fix taya's linux crash, thanks to taya and router!

Crash was due to invalidated iterator
This commit is contained in:
Liru Færs
2020-01-11 21:00:16 -05:00
parent c57fceff17
commit d1d42701f5

View File

@@ -139,22 +139,16 @@ void ScriptCounter::inventoryChanged(LLViewerObject* obj, LLInventoryObject::obj
if (inv) if (inv)
{ {
for (auto i = inv->begin(), end = inv->end(); i != end; ++i) uuid_vec_t ids;
if (LLInventoryObject* asset = *i)
if (asset->getType() == LLAssetType::AT_LSL_TEXT) for (auto asset : *inv)
{ {
const LLUUID& id = asset->getUUID(); const LLUUID& id = asset->getUUID();
if (asset->getType() == LLAssetType::AT_LSL_TEXT && id.notNull())
{
++scriptcount; ++scriptcount;
if (doDelete) if (doDelete)
{ ids.push_back(id);
if (id.notNull())
{
//LL_INFOS() << "Deleting script " << id << " in " << objid << LL_ENDL;
obj->removeInventory(id);
--i; // Avoid iteration when removing, everything has shifted
end = inv->end();
}
}
else else
{ {
LLMessageSystem* msg = gMessageSystem; LLMessageSystem* msg = gMessageSystem;
@@ -169,6 +163,13 @@ void ScriptCounter::inventoryChanged(LLViewerObject* obj, LLInventoryObject::obj
} }
} }
for (const auto& id : ids)
{
//LL_INFOS() << "Deleting script " << id << " in " << objid << LL_ENDL;
obj->removeInventory(id);
}
}
summarize(); summarize();
} }