mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Fix pathgrid segfault
This commit is contained in:
parent
f4110a72cc
commit
42b948dffe
@ -275,12 +275,14 @@ bool CSVRender::Cell::referenceAdded (const QModelIndex& parent, int start, int
|
|||||||
|
|
||||||
void CSVRender::Cell::pathgridModified()
|
void CSVRender::Cell::pathgridModified()
|
||||||
{
|
{
|
||||||
mPathgrid->recreateGeometry();
|
if (mPathgrid)
|
||||||
|
mPathgrid->recreateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Cell::pathgridRemoved()
|
void CSVRender::Cell::pathgridRemoved()
|
||||||
{
|
{
|
||||||
mPathgrid->removeGeometry();
|
if (mPathgrid)
|
||||||
|
mPathgrid->removeGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Cell::reloadAssets()
|
void CSVRender::Cell::reloadAssets()
|
||||||
@ -320,7 +322,7 @@ void CSVRender::Cell::setSelection (int elementMask, Selection mode)
|
|||||||
iter->second->setSelected (selected);
|
iter->second->setSelected (selected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (elementMask & Mask_Pathgrid)
|
if (mPathgrid && elementMask & Mask_Pathgrid)
|
||||||
{
|
{
|
||||||
// Only one pathgrid may be selected, so some operations will only have an effect
|
// Only one pathgrid may be selected, so some operations will only have an effect
|
||||||
// if the pathgrid is already focused
|
// if the pathgrid is already focused
|
||||||
@ -420,7 +422,7 @@ std::vector<osg::ref_ptr<CSVRender::TagBase> > CSVRender::Cell::getSelection (un
|
|||||||
iter!=mObjects.end(); ++iter)
|
iter!=mObjects.end(); ++iter)
|
||||||
if (iter->second->getSelected())
|
if (iter->second->getSelected())
|
||||||
result.push_back (iter->second->getTag());
|
result.push_back (iter->second->getTag());
|
||||||
if (elementMask & Mask_Pathgrid)
|
if (mPathgrid && elementMask & Mask_Pathgrid)
|
||||||
if (mPathgrid->isSelected())
|
if (mPathgrid->isSelected())
|
||||||
result.push_back(mPathgrid->getTag());
|
result.push_back(mPathgrid->getTag());
|
||||||
|
|
||||||
@ -457,6 +459,6 @@ void CSVRender::Cell::reset (unsigned int elementMask)
|
|||||||
for (std::map<std::string, Object *>::const_iterator iter (mObjects.begin());
|
for (std::map<std::string, Object *>::const_iterator iter (mObjects.begin());
|
||||||
iter!=mObjects.end(); ++iter)
|
iter!=mObjects.end(); ++iter)
|
||||||
iter->second->reset();
|
iter->second->reset();
|
||||||
if (elementMask & Mask_Pathgrid)
|
if (mPathgrid && elementMask & Mask_Pathgrid)
|
||||||
mPathgrid->resetIndicators();
|
mPathgrid->resetIndicators();
|
||||||
}
|
}
|
||||||
|
@ -72,12 +72,15 @@ namespace CSVRender
|
|||||||
}
|
}
|
||||||
else if (Cell* cell = getWorldspaceWidget().getCell (hitResult.worldPos))
|
else if (Cell* cell = getWorldspaceWidget().getCell (hitResult.worldPos))
|
||||||
{
|
{
|
||||||
// Add node
|
if (cell->getPathgrid())
|
||||||
QUndoStack& undoStack = getWorldspaceWidget().getDocument().getUndoStack();
|
{
|
||||||
QString description = "Add node";
|
// Add node
|
||||||
|
QUndoStack& undoStack = getWorldspaceWidget().getDocument().getUndoStack();
|
||||||
|
QString description = "Add node";
|
||||||
|
|
||||||
CSMWorld::CommandMacro macro(undoStack, description);
|
CSMWorld::CommandMacro macro(undoStack, description);
|
||||||
cell->getPathgrid()->applyPoint(macro, hitResult.worldPos);
|
cell->getPathgrid()->applyPoint(macro, hitResult.worldPos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +208,7 @@ namespace CSVRender
|
|||||||
WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask());
|
WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask());
|
||||||
|
|
||||||
Cell* cell = getWorldspaceWidget().getCell(hit.worldPos);
|
Cell* cell = getWorldspaceWidget().getCell(hit.worldPos);
|
||||||
if (cell)
|
if (cell && cell->getPathgrid())
|
||||||
{
|
{
|
||||||
PathgridTag* tag = 0;
|
PathgridTag* tag = 0;
|
||||||
if (hit.tag && (tag = dynamic_cast<PathgridTag*>(hit.tag.get())) && tag->getPathgrid()->getId() == mEdgeId)
|
if (hit.tag && (tag = dynamic_cast<PathgridTag*>(hit.tag.get())) && tag->getPathgrid()->getId() == mEdgeId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user