Fix potential segfault, cleanup, get rid of warnings.

new-script-api
Kyle Cooley 7 years ago
parent 72cb405de2
commit d030b595f8

@ -297,7 +297,6 @@ namespace CSMWorld
{ {
int index = cloneRecordImp(origin, destination, type); int index = cloneRecordImp(origin, destination, type);
mRecords.at(index).get().mPlugin = 0; mRecords.at(index).get().mPlugin = 0;
mRecords.at(index).get().mContext.filename.clear();
} }
template<typename ESXRecordT, typename IdAccessorT> template<typename ESXRecordT, typename IdAccessorT>
@ -313,7 +312,6 @@ namespace CSMWorld
if (index >= 0) if (index >= 0)
{ {
mRecords.at(index).get().mPlugin = 0; mRecords.at(index).get().mPlugin = 0;
mRecords.at(index).get().mContext.filename.clear();
return true; return true;
} }

@ -75,7 +75,7 @@ bool CSVRender::Cell::addObjects (int start, int end)
return modified; return modified;
} }
void CSVRender::Cell::createLand() void CSVRender::Cell::updateLand()
{ {
// Cell is deleted // Cell is deleted
if (mDeleted) if (mDeleted)
@ -152,7 +152,7 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::st
addObjects (0, rows-1); addObjects (0, rows-1);
createLand(); updateLand();
mPathgrid.reset(new Pathgrid(mData, mCellNode, mId, mCoordinates)); mPathgrid.reset(new Pathgrid(mData, mCellNode, mId, mCoordinates));
mCellWater.reset(new CellWater(mData, mCellNode, mId, mCoordinates)); mCellWater.reset(new CellWater(mData, mCellNode, mId, mCoordinates));
@ -325,32 +325,32 @@ void CSVRender::Cell::pathgridRemoved()
void CSVRender::Cell::landDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) void CSVRender::Cell::landDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight)
{ {
createLand(); updateLand();
} }
void CSVRender::Cell::landAboutToBeRemoved (const QModelIndex& parent, int start, int end) void CSVRender::Cell::landAboutToBeRemoved (const QModelIndex& parent, int start, int end)
{ {
createLand(); updateLand();
} }
void CSVRender::Cell::landAdded (const QModelIndex& parent, int start, int end) void CSVRender::Cell::landAdded (const QModelIndex& parent, int start, int end)
{ {
createLand(); updateLand();
} }
void CSVRender::Cell::landTextureChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) void CSVRender::Cell::landTextureChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight)
{ {
createLand(); updateLand();
} }
void CSVRender::Cell::landTextureAboutToBeRemoved (const QModelIndex& parent, int start, int end) void CSVRender::Cell::landTextureAboutToBeRemoved (const QModelIndex& parent, int start, int end)
{ {
createLand(); updateLand();
} }
void CSVRender::Cell::landTextureAdded (const QModelIndex& parent, int start, int end) void CSVRender::Cell::landTextureAdded (const QModelIndex& parent, int start, int end)
{ {
createLand(); updateLand();
} }
void CSVRender::Cell::reloadAssets() void CSVRender::Cell::reloadAssets()

@ -72,7 +72,7 @@ namespace CSVRender
/// \return Have any objects been added? /// \return Have any objects been added?
bool addObjects (int start, int end); bool addObjects (int start, int end);
void createLand(); void updateLand();
void unloadLand(); void unloadLand();
public: public:

@ -262,18 +262,17 @@ void CSVWorld::GenericCreator::cloneMode(const std::string& originId,
void CSVWorld::GenericCreator::touch(const std::vector<CSMWorld::UniversalId>& ids) void CSVWorld::GenericCreator::touch(const std::vector<CSMWorld::UniversalId>& ids)
{ {
// Combine multiple touch commands into one "macro" command // Combine multiple touch commands into one "macro" command
std::unique_ptr<QUndoCommand> macro(new QUndoCommand()); mUndoStack.beginMacro("Touch Records");
macro->setText("Touch records");
CSMWorld::IdTable& table = dynamic_cast<CSMWorld::IdTable&>(*mData.getTableModel(mListId)); CSMWorld::IdTable& table = dynamic_cast<CSMWorld::IdTable&>(*mData.getTableModel(mListId));
for (const CSMWorld::UniversalId& uid : ids) for (const CSMWorld::UniversalId& uid : ids)
{ {
// This is not leaked, touchCmd is a child of macro and managed by Qt CSMWorld::TouchCommand* touchCmd = new CSMWorld::TouchCommand(table, uid.getId());
CSMWorld::TouchCommand* touchCmd = new CSMWorld::TouchCommand(table, uid.getId(), macro.get()); mUndoStack.push(touchCmd);
} }
// Execute // Execute
mUndoStack.push(macro.release()); mUndoStack.endMacro();
} }
void CSVWorld::GenericCreator::toggleWidgets(bool active) void CSVWorld::GenericCreator::toggleWidgets(bool active)

@ -55,19 +55,18 @@ namespace CSVWorld
void LandCreator::touch(const std::vector<CSMWorld::UniversalId>& ids) void LandCreator::touch(const std::vector<CSMWorld::UniversalId>& ids)
{ {
// Combine multiple touch commands into one "macro" command // Combine multiple touch commands into one "macro" command
std::unique_ptr<QUndoCommand> macro(new QUndoCommand()); getUndoStack().beginMacro("Touch records");
macro->setText("Touch records");
CSMWorld::IdTable& lands = dynamic_cast<CSMWorld::IdTable&>(*getData().getTableModel(CSMWorld::UniversalId::Type_Lands)); CSMWorld::IdTable& lands = dynamic_cast<CSMWorld::IdTable&>(*getData().getTableModel(CSMWorld::UniversalId::Type_Lands));
CSMWorld::IdTable& ltexs = dynamic_cast<CSMWorld::IdTable&>(*getData().getTableModel(CSMWorld::UniversalId::Type_LandTextures)); CSMWorld::IdTable& ltexs = dynamic_cast<CSMWorld::IdTable&>(*getData().getTableModel(CSMWorld::UniversalId::Type_LandTextures));
for (const CSMWorld::UniversalId& uid : ids) for (const CSMWorld::UniversalId& uid : ids)
{ {
// This is not leaked, touchCmd is a child of macro and managed by Qt CSMWorld::TouchLandCommand* touchCmd = new CSMWorld::TouchLandCommand(lands, ltexs, uid.getId());
CSMWorld::TouchLandCommand* touchCmd = new CSMWorld::TouchLandCommand(lands, ltexs, uid.getId(), macro.get()); getUndoStack().push(touchCmd);
} }
// Execute // Execute
getUndoStack().push(macro.release()); getUndoStack().endMacro();
} }
void LandCreator::focus() void LandCreator::focus()

@ -238,7 +238,11 @@ namespace ESM
// Copy data to target if no file // Copy data to target if no file
if (mContext.filename.empty()) if (mContext.filename.empty())
{ {
*target = *mLandData; if (mLandData)
*target = *mLandData;
else
target = new LandData;
return; return;
} }

Loading…
Cancel
Save