Fix Crashes when touching non existing entry positions.

This commit is contained in:
StackZ
2019-12-24 01:03:43 +01:00
parent c092c63efe
commit 71e4ff0939
3 changed files with 23 additions and 24 deletions
+2 -2
View File
@@ -227,7 +227,7 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_TOUCH) { if (hDown & KEY_TOUCH) {
if (Config::viewMode == 0) { if (Config::viewMode == 0) {
for(int i=0;i<ENTRIES_PER_SCREEN;i++) { for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)infoJson.size();i++) {
if(touch.py > (i+1)*57 && touch.py < (i+2)*57) { if(touch.py > (i+1)*57 && touch.py < (i+2)*57) {
if (infoJson.size() != 0) { if (infoJson.size() != 0) {
std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[screenPos + i]["title"]); std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[screenPos + i]["title"]);
@@ -244,7 +244,7 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
} }
} }
} else if (Config::viewMode == 1) { } else if (Config::viewMode == 1) {
for(int i=0;i<ENTRIES_PER_LIST;i++) { for(int i=0;i<ENTRIES_PER_LIST && i<(int)infoJson.size();i++) {
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) { if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
if (infoJson.size() != 0) { if (infoJson.size() != 0) {
std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[screenPosList + i]["title"]); std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[screenPosList + i]["title"]);
+4 -4
View File
@@ -403,7 +403,7 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_TOUCH) { if (hDown & KEY_TOUCH) {
if (Config::viewMode == 0) { if (Config::viewMode == 0) {
for(int i=0;i<ENTRIES_PER_SCREEN; i++) { for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)fileInfo.size(); i++) {
if(touch.py > (i+1)*57 && touch.py < (i+2)*57) { if(touch.py > (i+1)*57 && touch.py < (i+2)*57) {
if (dirContents[screenPos + i].isDirectory) { if (dirContents[screenPos + i].isDirectory) {
} else if (fileInfo.size() != 0) { } else if (fileInfo.size() != 0) {
@@ -424,7 +424,7 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
} }
} }
} else if (Config::viewMode == 1) { } else if (Config::viewMode == 1) {
for(int i=0;i<ENTRIES_PER_LIST; i++) { for(int i=0;i<ENTRIES_PER_LIST && i<(int)fileInfo.size(); i++) {
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) { if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
if (dirContents[screenPosList + i].isDirectory) { if (dirContents[screenPosList + i].isDirectory) {
} else if (fileInfo.size() != 0) { } else if (fileInfo.size() != 0) {
@@ -541,7 +541,7 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_TOUCH) { if (hDown & KEY_TOUCH) {
if (Config::viewMode == 0) { if (Config::viewMode == 0) {
for(int i=0;i<ENTRIES_PER_SCREEN; i++) { for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)fileInfo2.size(); i++) {
if(touch.py > (i+1)*57 && touch.py < (i+2)*57) { if(touch.py > (i+1)*57 && touch.py < (i+2)*57) {
if (fileInfo2.size() != 0) { if (fileInfo2.size() != 0) {
choice = fileInfo2[screenPos2 + i]; choice = fileInfo2[screenPos2 + i];
@@ -550,7 +550,7 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) {
} }
} }
} else if (Config::viewMode == 1) { } else if (Config::viewMode == 1) {
for(int i=0;i<ENTRIES_PER_LIST; i++) { for(int i=0;i<ENTRIES_PER_LIST && i<(int)fileInfo2.size(); i++) {
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) { if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
if (fileInfo2.size() != 0) { if (fileInfo2.size() != 0) {
choice = fileInfo2[screenPosList2 + i]; choice = fileInfo2[screenPosList2 + i];
+2 -3
View File
@@ -77,7 +77,6 @@ TinyDB::TinyDB() {
selectedOption = tinyDBList[0]; selectedOption = tinyDBList[0];
} }
// To-Do.
void TinyDB::Draw(void) const { void TinyDB::Draw(void) const {
std::string info; std::string info;
Gui::setDraw(top); Gui::setDraw(top);
@@ -228,7 +227,7 @@ void TinyDB::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_TOUCH) { if (hDown & KEY_TOUCH) {
if (Config::viewMode == 0) { if (Config::viewMode == 0) {
for(int i=0;i<ENTRIES_PER_SCREEN;i++) { for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)tinyDBList.size();i++) {
if(touch.py > (i+1)*57 && touch.py < (i+2)*57) { if(touch.py > (i+1)*57 && touch.py < (i+2)*57) {
selection = screenPos + i; selection = screenPos + i;
selectedOption = tinyDBList[screenPos + i]; selectedOption = tinyDBList[screenPos + i];
@@ -236,7 +235,7 @@ void TinyDB::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
} }
} }
} else if (Config::viewMode == 1) { } else if (Config::viewMode == 1) {
for(int i=0;i<ENTRIES_PER_LIST;i++) { for(int i=0;i<ENTRIES_PER_LIST && i<(int)tinyDBList.size();i++) {
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) { if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
selection = screenPosList + i; selection = screenPosList + i;
selectedOption = tinyDBList[screenPosList + i]; selectedOption = tinyDBList[screenPosList + i];