mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 07:09:42 +00:00
Fix -Wreturn-local-addr warning
/home/elsid/dev/openmw/apps/opencs/model/world/actoradapter.cpp: In member function ‘const string& CSMWorld::ActorAdapter::ActorData::getPart(ESM::PartReferenceType) const’: /home/elsid/dev/openmw/apps/opencs/model/world/actoradapter.cpp:142:20: error: returning reference to temporary [-Werror=return-local-addr] 142 | return ""; | ^~
This commit is contained in:
parent
76320aae45
commit
a8c16071dc
3 changed files with 9 additions and 4 deletions
|
@ -9,6 +9,9 @@
|
|||
|
||||
#include "data.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
const std::string& ActorAdapter::RaceData::getId() const
|
||||
|
@ -121,7 +124,7 @@ namespace CSMWorld
|
|||
return SceneUtil::getActorSkeleton(firstPerson, mFemale, beast, werewolf);
|
||||
}
|
||||
|
||||
const std::string& ActorAdapter::ActorData::getPart(ESM::PartReferenceType index) const
|
||||
std::string_view ActorAdapter::ActorData::getPart(ESM::PartReferenceType index) const
|
||||
{
|
||||
auto it = mParts.find(index);
|
||||
if (it == mParts.end())
|
||||
|
@ -139,7 +142,7 @@ namespace CSMWorld
|
|||
return mRaceData->getMalePart(index);
|
||||
}
|
||||
|
||||
return "";
|
||||
return {};
|
||||
}
|
||||
|
||||
const std::string& partName = it->second.first;
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <array>
|
||||
#include <map>
|
||||
#include <unordered_set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <QObject>
|
||||
#include <QModelIndex>
|
||||
|
@ -93,7 +95,7 @@ namespace CSMWorld
|
|||
/// Returns the skeleton the actor should use for attaching parts to
|
||||
std::string getSkeleton() const;
|
||||
/// Retrieves the associated actor part
|
||||
const std::string& getPart(ESM::PartReferenceType index) const;
|
||||
std::string_view getPart(ESM::PartReferenceType index) const;
|
||||
/// Checks if the actor has a data dependency
|
||||
bool hasDependency(const std::string& id) const;
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace CSVRender
|
|||
for (int i = 0; i < ESM::PRT_Count; ++i)
|
||||
{
|
||||
auto type = (ESM::PartReferenceType) i;
|
||||
std::string partId = mActorData->getPart(type);
|
||||
const std::string partId(mActorData->getPart(type));
|
||||
attachBodyPart(type, getBodyPartMesh(partId));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue