fix texture corruption on ModsLayer

This commit is contained in:
Fleeym 2024-06-18 01:36:59 +03:00
parent 6e6daceb1c
commit 76e2ed47c6
3 changed files with 15 additions and 1 deletions

View file

@ -643,6 +643,12 @@ void ModsLayer::onRefreshList(CCObject*) {
}
}
void ModsLayer::onBack(CCObject*) {
// Tell every list that we are about to exit the layer.
// This prevents any page from being cached when the
// cache invalidation event fires.
for (auto& list : m_lists) {
list.second->setIsExiting(true);
}
CCDirector::get()->replaceScene(CCTransitionFade::create(.5f, MenuLayer::scene(false)));
// To avoid memory overloading, clear caches after leaving the layer

View file

@ -415,6 +415,10 @@ void ModList::onPromise(ModListSource::PageLoadTask::Event* event) {
}
}
void ModList::setIsExiting(bool exiting) {
m_exiting = true;
}
void ModList::onPage(CCObject* sender) {
// If no page count has been loaded yet, we can't do anything
if (!m_source->getPageCount()) return;
@ -470,7 +474,9 @@ void ModList::onCheckUpdates(typename server::ServerRequest<std::vector<std::str
}
void ModList::onInvalidateCache(InvalidateCacheEvent* event) {
this->gotoPage(0);
if (!m_exiting) {
this->gotoPage(0);
}
}
void ModList::activateSearch(bool activate) {

View file

@ -53,6 +53,7 @@ protected:
EventListener<server::ServerRequest<std::vector<std::string>>> m_checkUpdatesListener;
EventListener<server::ModDownloadFilter> m_downloadListener;
bool m_bigSize = false;
bool m_exiting = false;
std::atomic<size_t> m_searchInputThreads = 0;
bool init(ModListSource* src, CCSize const& size);
@ -83,4 +84,5 @@ public:
void updateState();
void updateSize(bool big);
void activateSearch(bool activate);
void setIsExiting(bool exiting);
};