1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-12-25 07:15:12 +02:00

Avoid crash on startup when no applications are found

The code cannot deal with there being no sections. After startup,
there will always be sections for the built-in actions. But before
those are added the lack of sections could be fatal.
This commit is contained in:
Maarten ter Huurne 2015-04-22 09:39:44 +02:00
parent 1a5da1fd94
commit 3db955c471

View File

@ -346,10 +346,10 @@ void Menu::freeLinks() {
}
vector<Link*> *Menu::sectionLinks(int i) {
if (i<0 || i>(int)links.size())
if (i<0 || i>=(int)links.size())
i = selSectionIndex();
if (i<0 || i>(int)links.size())
if (i<0 || i>=(int)links.size())
return NULL;
return &links[i];
@ -625,6 +625,11 @@ LinkApp *Menu::selLinkApp() {
}
void Menu::setLinkIndex(int i) {
auto links = sectionLinks();
if (!links) {
// No sections.
return;
}
const int numLinks = static_cast<int>(sectionLinks()->size());
if (i < 0)
i = numLinks - 1;