forked from mirror/openmw-tes3mp
fixed object removal via setting state to delete
This commit is contained in:
parent
c1f0aa7260
commit
790367b980
2 changed files with 31 additions and 13 deletions
|
@ -22,11 +22,18 @@ bool CSVRender::Cell::removeObject (const std::string& id)
|
||||||
if (iter==mObjects.end())
|
if (iter==mObjects.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
delete iter->second;
|
removeObject (iter);
|
||||||
mObjects.erase (iter);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<std::string, CSVRender::Object *>::iterator CSVRender::Cell::removeObject (
|
||||||
|
std::map<std::string, Object *>::iterator iter)
|
||||||
|
{
|
||||||
|
delete iter->second;
|
||||||
|
mObjects.erase (iter++);
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
bool CSVRender::Cell::addObjects (int start, int end)
|
bool CSVRender::Cell::addObjects (int start, int end)
|
||||||
{
|
{
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
|
@ -161,8 +168,8 @@ bool CSVRender::Cell::referenceDataChanged (const QModelIndex& topLeft,
|
||||||
// perform update and remove where needed
|
// perform update and remove where needed
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
|
|
||||||
for (std::map<std::string, Object *>::iterator iter (mObjects.begin());
|
std::map<std::string, Object *>::iterator iter = mObjects.begin();
|
||||||
iter!=mObjects.end(); ++iter)
|
while (iter!=mObjects.end())
|
||||||
{
|
{
|
||||||
if (iter->second->referenceDataChanged (topLeft, bottomRight))
|
if (iter->second->referenceDataChanged (topLeft, bottomRight))
|
||||||
modified = true;
|
modified = true;
|
||||||
|
@ -171,23 +178,30 @@ bool CSVRender::Cell::referenceDataChanged (const QModelIndex& topLeft,
|
||||||
|
|
||||||
if (iter2!=ids.end())
|
if (iter2!=ids.end())
|
||||||
{
|
{
|
||||||
if (iter2->second)
|
bool deleted = iter2->second;
|
||||||
{
|
|
||||||
removeObject (iter->first);
|
|
||||||
modified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ids.erase (iter2);
|
ids.erase (iter2);
|
||||||
|
|
||||||
|
if (deleted)
|
||||||
|
{
|
||||||
|
iter = removeObject (iter);
|
||||||
|
modified = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add new objects
|
// add new objects
|
||||||
for (std::map<std::string, bool>::iterator iter (ids.begin()); iter!=ids.end(); ++iter)
|
for (std::map<std::string, bool>::iterator iter (ids.begin()); iter!=ids.end(); ++iter)
|
||||||
{
|
{
|
||||||
mObjects.insert (std::make_pair (
|
if (!iter->second)
|
||||||
iter->first, new Object (mData, mCellNode, iter->first, false)));
|
{
|
||||||
|
mObjects.insert (std::make_pair (
|
||||||
|
iter->first, new Object (mData, mCellNode, iter->first, false)));
|
||||||
|
|
||||||
modified = true;
|
modified = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return modified;
|
return modified;
|
||||||
|
|
|
@ -49,6 +49,10 @@ namespace CSVRender
|
||||||
/// \return Was the object deleted?
|
/// \return Was the object deleted?
|
||||||
bool removeObject (const std::string& id);
|
bool removeObject (const std::string& id);
|
||||||
|
|
||||||
|
// Remove object and return iterator to next object.
|
||||||
|
std::map<std::string, Object *>::iterator removeObject (
|
||||||
|
std::map<std::string, Object *>::iterator iter);
|
||||||
|
|
||||||
/// Add objects from reference table that are within this cell.
|
/// Add objects from reference table that are within this cell.
|
||||||
///
|
///
|
||||||
/// \return Have any objects been added?
|
/// \return Have any objects been added?
|
||||||
|
|
Loading…
Reference in a new issue