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:
parent
60378a0dcb
commit
df6ce90c84
16 changed files with 73 additions and 81 deletions
|
@ -46,9 +46,7 @@
|
|||
AsyncImageFileView::AsyncImageFileView(const std::string &filename, UI::ImageSizeMode sizeMode, PrioritizedWorkQueue *wq, UI::LayoutParams *layoutParams)
|
||||
: UI::Clickable(layoutParams), canFocus_(true), filename_(filename), color_(0xFFFFFFFF), sizeMode_(sizeMode), textureFailed_(false), fixedSizeW_(0.0f), fixedSizeH_(0.0f) {}
|
||||
|
||||
AsyncImageFileView::~AsyncImageFileView() {
|
||||
delete texture_;
|
||||
}
|
||||
AsyncImageFileView::~AsyncImageFileView() {}
|
||||
|
||||
void AsyncImageFileView::GetContentDimensions(const UIContext &dc, float &w, float &h) const {
|
||||
if (texture_) {
|
||||
|
@ -75,16 +73,15 @@ void AsyncImageFileView::SetFilename(std::string filename) {
|
|||
if (filename_ != filename) {
|
||||
textureFailed_ = false;
|
||||
filename_ = filename;
|
||||
delete texture_;
|
||||
texture_ = nullptr;
|
||||
texture_.reset(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncImageFileView::Draw(UIContext &dc) {
|
||||
using namespace Draw;
|
||||
if (!texture_ && !textureFailed_ && !filename_.empty()) {
|
||||
texture_ = CreateTextureFromFile(dc.GetDrawContext(), filename_.c_str(), DETECT, true);
|
||||
if (!texture_)
|
||||
texture_ = std::move(CreateTextureFromFile(dc.GetDrawContext(), filename_.c_str(), DETECT, true));
|
||||
if (!texture_.get())
|
||||
textureFailed_ = true;
|
||||
}
|
||||
|
||||
|
@ -414,7 +411,7 @@ UI::EventReturn GamePauseScreen::OnSwitchUMD(UI::EventParams &e) {
|
|||
void GamePauseScreen::CallbackDeleteConfig(bool yes)
|
||||
{
|
||||
if (yes) {
|
||||
GameInfo *info = g_gameInfoCache->GetInfo(NULL, gamePath_, 0);
|
||||
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, 0);
|
||||
g_Config.unloadGameConfig();
|
||||
g_Config.deleteGameConfig(info->id);
|
||||
info->hasConfig = false;
|
||||
|
@ -428,7 +425,7 @@ UI::EventReturn GamePauseScreen::OnCreateConfig(UI::EventParams &e)
|
|||
g_Config.createGameConfig(gameId);
|
||||
g_Config.changeGameSpecific(gameId);
|
||||
g_Config.saveGameConfig(gameId);
|
||||
GameInfo *info = g_gameInfoCache->GetInfo(NULL, gamePath_, 0);
|
||||
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, 0);
|
||||
if (info) {
|
||||
info->hasConfig = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue