mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-07-17 00:22:27 -05:00
Fix user icon memory leak
This commit is contained in:
parent
5a7dc0e0e5
commit
4e6fa82e47
2
Makefile
2
Makefile
|
|
@ -38,7 +38,7 @@ INCLUDES := inc
|
|||
EXEFS_SRC := exefs_src
|
||||
APP_TITLE := JKSV
|
||||
APP_AUTHOR := JK
|
||||
APP_VERSION := 05.26.2020
|
||||
APP_VERSION := 06.01.2020
|
||||
ROMFS := romfs
|
||||
ICON := romfs/icon.jpg
|
||||
|
||||
|
|
|
|||
42
src/data.cpp
42
src/data.cpp
|
|
@ -122,17 +122,18 @@ bool data::loadUsersTitles(bool clearUsers)
|
|||
u.titles.clear();
|
||||
if(clearUsers)
|
||||
{
|
||||
for(data::user& u : data::users)
|
||||
u.delIcon();
|
||||
|
||||
data::users.clear();
|
||||
sysBCATPushed = false;
|
||||
cachePushed = false;
|
||||
tempPushed = false;
|
||||
users.emplace_back(util::u128ToAccountUID(3), "Device Saves", createDeviceIcon());
|
||||
users.emplace_back(util::u128ToAccountUID(2), "BCAT");
|
||||
users.emplace_back(util::u128ToAccountUID(1), "System");
|
||||
}
|
||||
|
||||
//Push system users
|
||||
users.emplace_back(util::u128ToAccountUID(3), "Device Saves", createDeviceIcon());
|
||||
users.emplace_back(util::u128ToAccountUID(2), "BCAT");
|
||||
users.emplace_back(util::u128ToAccountUID(1), "System");
|
||||
|
||||
NsApplicationControlData *dat = new NsApplicationControlData;
|
||||
while(R_SUCCEEDED(fsSaveDataInfoReaderRead(&it, &info, 1, &total)) && total != 0)
|
||||
{
|
||||
|
|
@ -179,20 +180,20 @@ bool data::loadUsersTitles(bool clearUsers)
|
|||
break;
|
||||
}
|
||||
|
||||
//If save data, not black listed or just ignore
|
||||
if(!blacklisted(info.application_id) && !blacklisted(info.save_data_id) && accountSystemSaveCheck(info))
|
||||
{
|
||||
int u = getUserIndex(info.uid);
|
||||
if(u == -1)
|
||||
{
|
||||
users.emplace(users.end() - 3, info.uid, "");
|
||||
u = getUserIndex(info.uid);
|
||||
}
|
||||
//Don't bother with this stuff
|
||||
if(blacklisted(info.application_id) || blacklisted(info.save_data_id) || !accountSystemSaveCheck(info))
|
||||
continue;
|
||||
|
||||
data::titledata newData(info, dat);
|
||||
if(!forceMount || newData.isMountable(data::users[u].getUID()))
|
||||
users[u].titles.push_back(newData);
|
||||
int u = getUserIndex(info.uid);
|
||||
if(u == -1)
|
||||
{
|
||||
users.emplace(users.end() - 3, info.uid, "");
|
||||
u = getUserIndex(info.uid);
|
||||
}
|
||||
|
||||
data::titledata newData(info, dat);
|
||||
if(!forceMount || newData.isMountable(data::users[u].getUID()))
|
||||
users[u].titles.push_back(newData);
|
||||
}
|
||||
delete dat;
|
||||
fsSaveDataInfoReaderClose(&it);
|
||||
|
|
@ -228,7 +229,7 @@ void data::init()
|
|||
setGetSystemLanguage(&lang);
|
||||
setMakeLanguage(lang, &sysLang);
|
||||
|
||||
data::loadUsersTitles(false);
|
||||
data::loadUsersTitles(true);
|
||||
}
|
||||
|
||||
void data::exit()
|
||||
|
|
@ -327,7 +328,8 @@ data::titledata::titledata(const FsSaveDataInfo& inf, NsApplicationControlData *
|
|||
|
||||
bool data::titledata::isMountable(const AccountUid& uid)
|
||||
{
|
||||
data::user tmpUser(uid, "");
|
||||
data::user tmpUser;
|
||||
tmpUser.setUID(uid);
|
||||
if(fs::mountSave(tmpUser, *this))
|
||||
{
|
||||
fs::unmountSave();
|
||||
|
|
@ -375,8 +377,6 @@ data::user::user(const AccountUid& _id, const std::string& _backupName)
|
|||
userSafe = _backupName.empty() ? getIDStr((uint64_t)uID128) : _backupName;
|
||||
userIcon = util::createIconGeneric(_backupName.c_str());
|
||||
}
|
||||
|
||||
titles.reserve(64);
|
||||
}
|
||||
|
||||
data::user::user(const AccountUid& _id, const std::string& _backupName, tex *img) : user(_id, _backupName)
|
||||
|
|
|
|||
13
src/file.cpp
13
src/file.cpp
|
|
@ -19,6 +19,8 @@ static std::string wd;
|
|||
|
||||
static FSFILE *log;
|
||||
|
||||
static FsFileSystem sv;
|
||||
|
||||
static struct
|
||||
{
|
||||
bool operator()(fs::dirItem& a, fs::dirItem& b)
|
||||
|
|
@ -214,8 +216,6 @@ void fs::exit()
|
|||
bool fs::mountSave(data::user& usr, data::titledata& open)
|
||||
{
|
||||
Result svOpen;
|
||||
FsFileSystem sv;
|
||||
|
||||
switch(open.getType())
|
||||
{
|
||||
case FsSaveDataType_System:
|
||||
|
|
@ -368,7 +368,14 @@ std::string fs::dataFile::getNextValueStr()
|
|||
|
||||
int fs::dataFile::getNextValueInt()
|
||||
{
|
||||
return strtol(getNextValueStr().c_str(), 0, 10);
|
||||
int ret = 0;
|
||||
std::string no = getNextValueStr();
|
||||
if(no[0] == '0' && tolower(no[1]) == 'x')
|
||||
ret = strtoul(no.c_str(), NULL, 16);
|
||||
else
|
||||
ret = strtoul(no.c_str(), NULL, 10);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void fs::copyFile(const std::string& from, const std::string& to)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include "util.h"
|
||||
#include "file.h"
|
||||
|
||||
#define VER_STRING "v. 05.26.2020"
|
||||
#define VER_STRING "v. 06.01.2020"
|
||||
|
||||
//text mode
|
||||
bool ui::textMode = false;
|
||||
|
|
|
|||
|
|
@ -135,7 +135,6 @@ void ui::updateFolderMenu(const uint64_t& down, const uint64_t& held)
|
|||
data::curData.icon.draw(96, 98);
|
||||
drawTextWrap(folderMenuInfo.c_str(), frameBuffer, ui::shared, 60, 370, 16, ui::txtCont, 360);
|
||||
|
||||
|
||||
if(down & KEY_A)
|
||||
{
|
||||
if(folderMenu.getSelected() == 0)
|
||||
|
|
@ -159,7 +158,7 @@ void ui::updateFolderMenu(const uint64_t& down, const uint64_t& held)
|
|||
}
|
||||
else if(down & KEY_B)
|
||||
{
|
||||
fsdevUnmountDevice("sv");
|
||||
fs::unmountSave();
|
||||
mstate = TTL_SEL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,12 +155,11 @@ void ui::updateTitleMenu(const uint64_t& down, const uint64_t& held)
|
|||
}
|
||||
else if(down & KEY_ZR)
|
||||
{
|
||||
data::titledata tempData = data::curUser.titles[data::selData];
|
||||
if(tempData.getType() == FsSaveDataType_System)
|
||||
if(data::curData.getType() == FsSaveDataType_System)
|
||||
ui::showMessage("*NO*", "Deleting system save archives is disabled.");
|
||||
else if(confirm(true, ui::confEraseNand.c_str(), tempData.getTitle().c_str()))
|
||||
else if(confirm(true, ui::confEraseNand.c_str(), data::curData.getTitle().c_str()))
|
||||
{
|
||||
fsDeleteSaveDataFileSystemBySaveDataSpaceId(FsSaveDataSpaceId_User, tempData.getSaveID());
|
||||
fsDeleteSaveDataFileSystemBySaveDataSpaceId(FsSaveDataSpaceId_User, data::curData.getSaveID());
|
||||
data::loadUsersTitles(false);
|
||||
data::selData = 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user