mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-24 11:43:05 +01:00
copying class with pointers as member when deleting them in the desctructor is danger zone.
This commit is contained in:
parent
ef108ae4d6
commit
79eaffaaa7
@ -21,21 +21,38 @@ struct sceNpTrophyInternalContext
|
||||
{
|
||||
// TODO
|
||||
std::string trp_name;
|
||||
vfsStream* trp_stream;
|
||||
std::unique_ptr<vfsStream> trp_stream;
|
||||
|
||||
TROPUSRLoader* tropusr;
|
||||
std::unique_ptr<TROPUSRLoader> tropusr;
|
||||
|
||||
//TODO: remove the following code when Visual C++ no longer generates
|
||||
//compiler errors for it. All of this should be auto-generated
|
||||
#if _MSC_VER <= 1800
|
||||
sceNpTrophyInternalContext()
|
||||
: trp_stream(nullptr),
|
||||
tropusr(nullptr)
|
||||
: trp_stream(),
|
||||
tropusr()
|
||||
{
|
||||
}
|
||||
|
||||
~sceNpTrophyInternalContext()
|
||||
sceNpTrophyInternalContext(sceNpTrophyInternalContext&& other)
|
||||
{
|
||||
safe_delete(trp_stream);
|
||||
safe_delete(tropusr);
|
||||
std::swap(trp_stream,other.trp_stream);
|
||||
std::swap(tropusr, other.tropusr);
|
||||
std::swap(trp_name, other.trp_name);
|
||||
}
|
||||
|
||||
sceNpTrophyInternalContext& operator =(sceNpTrophyInternalContext&& other)
|
||||
{
|
||||
std::swap(trp_stream, other.trp_stream);
|
||||
std::swap(tropusr, other.tropusr);
|
||||
std::swap(trp_name, other.trp_name);
|
||||
return *this;
|
||||
}
|
||||
|
||||
sceNpTrophyInternalContext(sceNpTrophyInternalContext& other) = delete;
|
||||
sceNpTrophyInternalContext& operator =(sceNpTrophyInternalContext& other) = delete;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
struct sceNpTrophyInternal
|
||||
@ -92,10 +109,10 @@ int sceNpTrophyCreateContext(mem32_t context, mem_ptr_t<SceNpCommunicationId> co
|
||||
|
||||
if (stream && stream->IsOpened())
|
||||
{
|
||||
sceNpTrophyInternalContext ctxt;
|
||||
ctxt.trp_stream = stream;
|
||||
s_npTrophyInstance.contexts.emplace_back();
|
||||
sceNpTrophyInternalContext& ctxt = s_npTrophyInstance.contexts.back();
|
||||
ctxt.trp_stream.reset(stream);
|
||||
ctxt.trp_name = entry->name;
|
||||
s_npTrophyInstance.contexts.push_back(ctxt);
|
||||
stream = nullptr;
|
||||
return CELL_OK;
|
||||
}
|
||||
@ -178,7 +195,7 @@ int sceNpTrophyRegisterContext(u32 context, u32 handle, u32 statusCb_addr, u32 a
|
||||
std::string trophyUsrPath = trophyPath + "/TROPUSR.DAT";
|
||||
std::string trophyConfPath = trophyPath + "/TROPCONF.SFM";
|
||||
tropusr->Load(trophyUsrPath, trophyConfPath);
|
||||
ctxt.tropusr = tropusr;
|
||||
ctxt.tropusr.reset(tropusr);
|
||||
|
||||
// TODO: Callbacks
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user