mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-23 22:53:09 +00:00
Fix warning: -Wmaybe-uninitialized
In file included from apps/opencs/model/world/pathgrid.hpp:7,
from apps/opencs/model/world/idcollection.hpp:15,
from apps/opencs/model/world/idcollection.cpp:1:
In constructor ‘constexpr ESM::Pathgrid::Pathgrid(ESM::Pathgrid&&)’,
inlined from ‘constexpr CSMWorld::Pathgrid::Pathgrid(CSMWorld::Pathgrid&&)’ at apps/opencs/model/world/pathgrid.hpp:24:12,
inlined from ‘constexpr CSMWorld::Record<CSMWorld::Pathgrid>::Record(CSMWorld::Record<CSMWorld::Pathgrid>&&)’ at apps/opencs/model/world/record.hpp:39:12,
inlined from ‘std::__detail::__unique_ptr_t<_Tp> std::make_unique(_Args&& ...) [with _Tp = CSMWorld::Record<CSMWorld::Pathgrid>; _Args = {CSMWorld::Record<CSMWorld::Pathgrid>}]’ at /usr/include/c++/13.2.1/bits/unique_ptr.h:1070:30,
inlined from ‘std::unique_ptr<CSMWorld::RecordBase> CSMWorld::Record<ESXRecordT>::modifiedCopy() const [with ESXRecordT = CSMWorld::Pathgrid]’ at apps/opencs/model/world/record.hpp:92:116:
components/esm3/loadpgrd.hpp:19:12: warning: ‘<unnamed>.CSMWorld::Record<CSMWorld::Pathgrid>::mBase.CSMWorld::Pathgrid::<unnamed>.ESM::Pathgrid::mData’ may be used uninitialized [-Wmaybe-uninitialized]
19 | struct Pathgrid
| ^~~~~~~~
In file included from apps/opencs/model/world/idcollection.hpp:8:
apps/opencs/model/world/record.hpp: In member function ‘std::unique_ptr<CSMWorld::RecordBase> CSMWorld::Record<ESXRecordT>::modifiedCopy() const [with ESXRecordT = CSMWorld::Pathgrid]’:
apps/opencs/model/world/record.hpp:92:53: note: ‘<anonymous>’ declared here
92 | return std::make_unique<Record<ESXRecordT>>(Record<ESXRecordT>(State_ModifiedOnly, nullptr, &(this->get())));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:
parent
9b412bc802
commit
9ae7b542c6
1 changed files with 10 additions and 8 deletions
|
|
@ -19,6 +19,11 @@ namespace CSMWorld
|
||||||
|
|
||||||
State mState;
|
State mState;
|
||||||
|
|
||||||
|
explicit RecordBase(State state)
|
||||||
|
: mState(state)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~RecordBase() = default;
|
virtual ~RecordBase() = default;
|
||||||
|
|
||||||
virtual std::unique_ptr<RecordBase> clone() const = 0;
|
virtual std::unique_ptr<RecordBase> clone() const = 0;
|
||||||
|
|
@ -69,21 +74,18 @@ namespace CSMWorld
|
||||||
|
|
||||||
template <typename ESXRecordT>
|
template <typename ESXRecordT>
|
||||||
Record<ESXRecordT>::Record()
|
Record<ESXRecordT>::Record()
|
||||||
: mBase()
|
: RecordBase(State_BaseOnly)
|
||||||
|
, mBase()
|
||||||
, mModified()
|
, mModified()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ESXRecordT>
|
template <typename ESXRecordT>
|
||||||
Record<ESXRecordT>::Record(State state, const ESXRecordT* base, const ESXRecordT* modified)
|
Record<ESXRecordT>::Record(State state, const ESXRecordT* base, const ESXRecordT* modified)
|
||||||
|
: RecordBase(state)
|
||||||
|
, mBase(base == nullptr ? ESXRecordT{} : *base)
|
||||||
|
, mModified(modified == nullptr ? ESXRecordT{} : *modified)
|
||||||
{
|
{
|
||||||
if (base)
|
|
||||||
mBase = *base;
|
|
||||||
|
|
||||||
if (modified)
|
|
||||||
mModified = *modified;
|
|
||||||
|
|
||||||
this->mState = state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ESXRecordT>
|
template <typename ESXRecordT>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue