Skip to content

Commit

Permalink
convert std::autor_ptr to std::unique_ptr, originally by Ewan Higgs a…
Browse files Browse the repository at this point in the history
…nd updated by Bret Curtis
  • Loading branch information
ehiggs authored and psi29a committed Jun 9, 2017
1 parent 27a5c06 commit 38a2de3
Show file tree
Hide file tree
Showing 75 changed files with 125 additions and 131 deletions.
2 changes: 1 addition & 1 deletion apps/opencs/editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace CS
Q_OBJECT

// FIXME: should be moved to document, so we can have different resources for each opened project
std::auto_ptr<VFS::Manager> mVFS;
std::unique_ptr<VFS::Manager> mVFS;

Files::ConfigurationManager mCfgMgr;
CSMPrefs::State mSettingsState;
Expand Down
4 changes: 2 additions & 2 deletions apps/opencs/model/doc/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ void CSMDoc::Document::runSearch (const CSMWorld::UniversalId& searchId, const C
emit stateChanged (getState(), this);
}

void CSMDoc::Document::runMerge (std::auto_ptr<CSMDoc::Document> target)
void CSMDoc::Document::runMerge (std::unique_ptr<CSMDoc::Document> target)
{
mTools.runMerge (target);
mTools.runMerge (std::move(target));
emit stateChanged (getState(), this);
}

Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/model/doc/document.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace CSMDoc

void runSearch (const CSMWorld::UniversalId& searchId, const CSMTools::Search& search);

void runMerge (std::auto_ptr<CSMDoc::Document> target);
void runMerge (std::unique_ptr<CSMDoc::Document> target);

void abortOperation (int type);

Expand Down
4 changes: 2 additions & 2 deletions apps/opencs/model/tools/mergeoperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ CSMTools::MergeOperation::MergeOperation (CSMDoc::Document& document, ToUTF8::Fr
appendStage (new FinishMergedDocumentStage (mState, encoding));
}

void CSMTools::MergeOperation::setTarget (std::auto_ptr<CSMDoc::Document> document)
void CSMTools::MergeOperation::setTarget (std::unique_ptr<CSMDoc::Document> document)
{
mState.mTarget = document;
mState.mTarget = std::move(document);
}

void CSMTools::MergeOperation::operationDone()
Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/model/tools/mergeoperation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace CSMTools
MergeOperation (CSMDoc::Document& document, ToUTF8::FromType encoding);

/// \attention Do not call this function while a merge is running.
void setTarget (std::auto_ptr<CSMDoc::Document> document);
void setTarget (std::unique_ptr<CSMDoc::Document> document);

protected slots:

Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/model/tools/mergestate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace CSMTools
{
struct MergeState
{
std::auto_ptr<CSMDoc::Document> mTarget;
std::unique_ptr<CSMDoc::Document> mTarget;
CSMDoc::Document& mSource;
bool mCompleted;
std::map<std::pair<uint16_t, int>, int> mTextureIndices; // (texture, content file) -> new texture
Expand Down
4 changes: 2 additions & 2 deletions apps/opencs/model/tools/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void CSMTools::Tools::runSearch (const CSMWorld::UniversalId& searchId, const Se
mSearch.start();
}

void CSMTools::Tools::runMerge (std::auto_ptr<CSMDoc::Document> target)
void CSMTools::Tools::runMerge (std::unique_ptr<CSMDoc::Document> target)
{
// not setting an active report, because merge does not produce messages

Expand All @@ -230,7 +230,7 @@ void CSMTools::Tools::runMerge (std::auto_ptr<CSMDoc::Document> target)

target->flagAsDirty();

mMergeOperation->setTarget (target);
mMergeOperation->setTarget (std::move(target));

mMerge.start();
}
Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/model/tools/tools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace CSMTools

void runSearch (const CSMWorld::UniversalId& searchId, const Search& search);

void runMerge (std::auto_ptr<CSMDoc::Document> target);
void runMerge (std::unique_ptr<CSMDoc::Document> target);

void abortOperation (int type);
///< \attention The operation is not aborted immediately.
Expand Down
4 changes: 2 additions & 2 deletions apps/opencs/model/world/commanddispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *model, cons
if (mLocked)
return;

std::auto_ptr<CSMWorld::UpdateCellCommand> modifyCell;
std::unique_ptr<CSMWorld::UpdateCellCommand> modifyCell;

int columnId = model->data (index, ColumnBase::Role_ColumnId).toInt();

Expand Down Expand Up @@ -167,7 +167,7 @@ void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *model, cons
}
}

std::auto_ptr<CSMWorld::ModifyCommand> modifyData (
std::unique_ptr<CSMWorld::ModifyCommand> modifyData (
new CSMWorld::ModifyCommand (*model, index, new_));

if (modifyCell.get())
Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/model/world/refidcollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ void CSMWorld::RefIdCollection::cloneRecord(const std::string& origin,
const std::string& destination,
const CSMWorld::UniversalId::Type type)
{
std::auto_ptr<RecordBase> newRecord(mData.getRecord(mData.searchId(origin)).modifiedCopy());
std::unique_ptr<RecordBase> newRecord(mData.getRecord(mData.searchId(origin)).modifiedCopy());
mAdapters.find(type)->second->setId(*newRecord, destination);
mData.insertRecord(*newRecord, type, destination);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/model/world/refiddata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ void CSMWorld::RefIdData::copyTo (int index, RefIdData& target) const

std::string id = source->getId (localIndex.first);

std::auto_ptr<CSMWorld::RecordBase> newRecord (source->getRecord (localIndex.first).modifiedCopy());
std::unique_ptr<CSMWorld::RecordBase> newRecord (source->getRecord (localIndex.first).modifiedCopy());

target.insertRecord (*newRecord, localIndex.second, id);
}
2 changes: 1 addition & 1 deletion apps/opencs/view/render/cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool CSVRender::Cell::addObjects (int start, int end)
{
std::string id = Misc::StringUtils::lowerCase (collection.getRecord (i).get().mId);

std::auto_ptr<Object> object (new Object (mData, mCellNode, id, false));
std::unique_ptr<Object> object (new Object (mData, mCellNode, id, false));

if (mSubModeElementMask & Mask_Reference)
object->setSubMode (mSubMode);
Expand Down
12 changes: 6 additions & 6 deletions apps/opencs/view/render/cell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ namespace CSVRender
std::string mId;
osg::ref_ptr<osg::Group> mCellNode;
std::map<std::string, Object *> mObjects;
std::auto_ptr<Terrain::TerrainGrid> mTerrain;
std::unique_ptr<Terrain::TerrainGrid> mTerrain;
CSMWorld::CellCoordinates mCoordinates;
std::auto_ptr<CellArrow> mCellArrows[4];
std::auto_ptr<CellMarker> mCellMarker;
std::auto_ptr<CellBorder> mCellBorder;
std::auto_ptr<CellWater> mCellWater;
std::auto_ptr<Pathgrid> mPathgrid;
std::unique_ptr<CellArrow> mCellArrows[4];
std::unique_ptr<CellMarker> mCellMarker;
std::unique_ptr<CellBorder> mCellBorder;
std::unique_ptr<CellWater> mCellWater;
std::unique_ptr<Pathgrid> mPathgrid;
bool mDeleted;
int mSubMode;
unsigned int mSubModeElementMask;
Expand Down
4 changes: 2 additions & 2 deletions apps/opencs/view/render/instancemode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ void CSVRender::InstanceMode::dropEvent (QDropEvent* event)

if (mode=="Create cell and insert")
{
std::auto_ptr<CSMWorld::CreateCommand> createCommand (
std::unique_ptr<CSMWorld::CreateCommand> createCommand (
new CSMWorld::CreateCommand (cellTable, cellId));

int parentIndex = cellTable.findColumnIndex (CSMWorld::Columns::ColumnId_Cell);
Expand Down Expand Up @@ -610,7 +610,7 @@ void CSVRender::InstanceMode::dropEvent (QDropEvent* event)
if (mime->isReferencable (iter->getType()))
{
// create reference
std::auto_ptr<CSMWorld::CreateCommand> createCommand (
std::unique_ptr<CSMWorld::CreateCommand> createCommand (
new CSMWorld::CreateCommand (
referencesTable, document.getData().getReferences().getNewId()));

Expand Down
4 changes: 2 additions & 2 deletions apps/opencs/view/render/pagedworldspacewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
{
modified = true;

std::auto_ptr<Cell> cell (new Cell (mDocument.getData(), mRootNode,
std::unique_ptr<Cell> cell (new Cell (mDocument.getData(), mRootNode,
iter->first.getId (mWorldspace), deleted));

delete iter->second;
Expand Down Expand Up @@ -378,7 +378,7 @@ void CSVRender::PagedWorldspaceWidget::addCellToScene (
bool deleted = index==-1 ||
cells.getRecord (index).mState==CSMWorld::RecordBase::State_Deleted;

std::auto_ptr<Cell> cell (
std::unique_ptr<Cell> cell (
new Cell (mDocument.getData(), mRootNode, coordinates.getId (mWorldspace),
deleted));
EditMode *editMode = getEditMode();
Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/view/render/unpagedworldspacewidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace CSVRender
std::string mCellId;
CSMWorld::IdTable *mCellsModel;
CSMWorld::IdTable *mReferenceablesModel;
std::auto_ptr<Cell> mCell;
std::unique_ptr<Cell> mCell;

void update();

Expand Down
4 changes: 2 additions & 2 deletions apps/opencs/view/tools/merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ void CSVTools::Merge::accept()
{
std::vector< boost::filesystem::path > files (1, mAdjuster->getPath());

std::auto_ptr<CSMDoc::Document> target (
std::unique_ptr<CSMDoc::Document> target (
mDocumentManager.makeDocument (files, files[0], true));

mDocument->runMerge (target);
mDocument->runMerge (std::move(target));

hide();
}
Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/view/world/creator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace CSVWorld
Creator *CreatorFactory<CreatorT, scope>::makeCreator (CSMDoc::Document& document,
const CSMWorld::UniversalId& id) const
{
std::auto_ptr<CreatorT> creator (new CreatorT (document.getData(), document.getUndoStack(), id));
std::unique_ptr<CreatorT> creator (new CreatorT (document.getData(), document.getUndoStack(), id));

creator->setScope (scope);

Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/view/world/dialoguesubview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ mIndex(index)
CSVWorld::DialogueDelegateDispatcherProxy::DialogueDelegateDispatcherProxy(QWidget* editor, CSMWorld::ColumnBase::Display display) :
mEditor(editor),
mDisplay(display),
mIndexWrapper(NULL)
mIndexWrapper(nullptr)
{
}

Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/view/world/dialoguesubview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace CSVWorld

CSMWorld::ColumnBase::Display mDisplay;

std::auto_ptr<refWrapper> mIndexWrapper;
std::unique_ptr<refWrapper> mIndexWrapper;

public:
DialogueDelegateDispatcherProxy(QWidget* editor,
Expand Down
6 changes: 3 additions & 3 deletions apps/opencs/view/world/genericcreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ std::string CSVWorld::GenericCreator::getIdValidatorResult() const

void CSVWorld::GenericCreator::configureCreateCommand (CSMWorld::CreateCommand& command) const {}

void CSVWorld::GenericCreator::pushCommand (std::auto_ptr<CSMWorld::CreateCommand> command,
void CSVWorld::GenericCreator::pushCommand (std::unique_ptr<CSMWorld::CreateCommand> command,
const std::string& id)
{
mUndoStack.push (command.release());
Expand Down Expand Up @@ -224,7 +224,7 @@ void CSVWorld::GenericCreator::create()
{
std::string id = getId();

std::auto_ptr<CSMWorld::CreateCommand> command;
std::unique_ptr<CSMWorld::CreateCommand> command;

if (mCloneMode)
{
Expand All @@ -239,7 +239,7 @@ void CSVWorld::GenericCreator::create()
}

configureCreateCommand (*command);
pushCommand (command, id);
pushCommand (std::move(command), id);

emit done();
emit requestFocus(id);
Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/view/world/genericcreator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace CSVWorld

/// Allow subclasses to wrap the create command together with additional commands
/// into a macro.
virtual void pushCommand (std::auto_ptr<CSMWorld::CreateCommand> command,
virtual void pushCommand (std::unique_ptr<CSMWorld::CreateCommand> command,
const std::string& id);

CSMWorld::Data& getData() const;
Expand Down
4 changes: 2 additions & 2 deletions apps/openmw/engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ namespace OMW
class Engine
{
SDL_Window* mWindow;
std::auto_ptr<VFS::Manager> mVFS;
std::auto_ptr<Resource::ResourceSystem> mResourceSystem;
std::unique_ptr<VFS::Manager> mVFS;
std::unique_ptr<Resource::ResourceSystem> mResourceSystem;
osg::ref_ptr<SceneUtil::WorkQueue> mWorkQueue;
MWBase::Environment mEnvironment;
ToUTF8::FromType mEncoding;
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ int main(int argc, char**argv)

boost::filesystem::ofstream logfile;

std::auto_ptr<OMW::Engine> engine;
std::unique_ptr<OMW::Engine> engine;

int ret = 0;
try
Expand Down
4 changes: 2 additions & 2 deletions apps/openmw/mwclass/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace MWClass
{
if (!ptr.getRefData().getCustomData())
{
std::auto_ptr<ContainerCustomData> data (new ContainerCustomData);
std::unique_ptr<ContainerCustomData> data (new ContainerCustomData);

MWWorld::LiveCellRef<ESM::Container> *ref =
ptr.get<ESM::Container>();
Expand Down Expand Up @@ -308,7 +308,7 @@ namespace MWClass
if (!ptr.getRefData().getCustomData())
{
// Create a CustomData, but don't fill it from ESM records (not needed)
std::auto_ptr<ContainerCustomData> data (new ContainerCustomData);
std::unique_ptr<ContainerCustomData> data (new ContainerCustomData);
ptr.getRefData().setCustomData (data.release());
}

Expand Down
4 changes: 2 additions & 2 deletions apps/openmw/mwclass/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace MWClass
{
if (!ptr.getRefData().getCustomData())
{
std::auto_ptr<CreatureCustomData> data (new CreatureCustomData);
std::unique_ptr<CreatureCustomData> data (new CreatureCustomData);

MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();

Expand Down Expand Up @@ -742,7 +742,7 @@ namespace MWClass
if (!ptr.getRefData().getCustomData())
{
// Create a CustomData, but don't fill it from ESM records (not needed)
std::auto_ptr<CreatureCustomData> data (new CreatureCustomData);
std::unique_ptr<CreatureCustomData> data (new CreatureCustomData);

if (hasInventoryStore(ptr))
data->mContainerStore = new MWWorld::InventoryStore();
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwclass/creaturelevlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ namespace MWClass
{
if (!ptr.getRefData().getCustomData())
{
std::auto_ptr<CreatureLevListCustomData> data (new CreatureLevListCustomData);
std::unique_ptr<CreatureLevListCustomData> data (new CreatureLevListCustomData);
data->mSpawnActorId = -1;
data->mSpawn = true;

Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwclass/door.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ namespace MWClass
{
if (!ptr.getRefData().getCustomData())
{
std::auto_ptr<DoorCustomData> data(new DoorCustomData);
std::unique_ptr<DoorCustomData> data(new DoorCustomData);

data->mDoorState = 0;
ptr.getRefData().setCustomData(data.release());
Expand Down
4 changes: 2 additions & 2 deletions apps/openmw/mwclass/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ namespace MWClass
{
if (!ptr.getRefData().getCustomData())
{
std::auto_ptr<NpcCustomData> data(new NpcCustomData);
std::unique_ptr<NpcCustomData> data(new NpcCustomData);

MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();

Expand Down Expand Up @@ -1259,7 +1259,7 @@ namespace MWClass
if (!ptr.getRefData().getCustomData())
{
// Create a CustomData, but don't fill it from ESM records (not needed)
std::auto_ptr<NpcCustomData> data (new NpcCustomData);
std::unique_ptr<NpcCustomData> data (new NpcCustomData);
ptr.getRefData().setCustomData (data.release());
}
}
Expand Down
4 changes: 3 additions & 1 deletion apps/openmw/mwgui/alchemywindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <vector>

#include "../mwmechanics/alchemy.hpp"

#include "widgets.hpp"
#include "windowbase.hpp"

Expand Down Expand Up @@ -48,7 +50,7 @@ namespace MWGui

void update();

std::auto_ptr<MWMechanics::Alchemy> mAlchemy;
std::unique_ptr<MWMechanics::Alchemy> mAlchemy;

std::vector<ItemWidget*> mApparatus;
std::vector<ItemWidget*> mIngredients;
Expand Down
Loading

0 comments on commit 38a2de3

Please sign in to comment.