mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-30 01:33:45 +01:00
When what we need is a shared_ptr, we should just go ahead and use one.
One of the top crashes reported in the Play Console is a ManagedTexture crash, so seeing if this might help.
This commit is contained in:
1 parent
60378a0dcb
commit
df6ce90c84
16 files changed
+73
-81
No files matched your search
+7
-7
@@ -153,23 +153,23 @@ bool ManagedTexture::LoadFromFile(const std::string &filename, ImageFileType typ
|
||||
return retval;
|
||||
}
|
||||
|
||||
ManagedTexture *CreateTextureFromFile(Draw::DrawContext *draw, const char *filename, ImageFileType type, bool generateMips) {
|
||||
std::unique_ptr<ManagedTexture> CreateTextureFromFile(Draw::DrawContext *draw, const char *filename, ImageFileType type, bool generateMips) {
|
||||
if (!draw)
|
||||
return nullptr;
|
||||
return std::unique_ptr<ManagedTexture>();
|
||||
// TODO: Load the texture on a background thread.
|
||||
ManagedTexture *mtex = new ManagedTexture(draw);
|
||||
if (!mtex->LoadFromFile(filename, type, generateMips)) {
|
||||
delete mtex;
|
||||
return nullptr;
|
||||
return std::unique_ptr<ManagedTexture>();
|
||||
}
|
||||
return mtex;
|
||||
return std::move(std::unique_ptr<ManagedTexture>(mtex));
|
||||
}
|
||||
|
||||
// TODO: Remove the code duplication between this and LoadFromFileData
|
||||
ManagedTexture *CreateTextureFromFileData(Draw::DrawContext *draw, const uint8_t *data, int size, ImageFileType type, bool generateMips) {
|
||||
std::unique_ptr<ManagedTexture> CreateTextureFromFileData(Draw::DrawContext *draw, const uint8_t *data, int size, ImageFileType type, bool generateMips) {
|
||||
if (!draw)
|
||||
return nullptr;
|
||||
return std::unique_ptr<ManagedTexture>();
|
||||
ManagedTexture *mtex = new ManagedTexture(draw);
|
||||
mtex->LoadFromFileData(data, size, type, generateMips);
|
||||
return mtex;
|
||||
return std::move(std::unique_ptr<ManagedTexture>(mtex));
|
||||
}
|
||||
Reference in new issue
Block a user