mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 08:44:39 +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:
parent
1a5da1fd94
commit
3db955c471
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user