1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-05 08:39:23 +02:00

Require valid section index passed to Menu::addActionLink

All calls to this method are in GMenu2X::initMenu() and they will only
pass valid indices, so the range check was redundant. Also the return
value was never used.

Added an assert to spot any invalid indices from future code.
This commit is contained in:
Maarten ter Huurne 2014-08-12 06:42:58 +02:00
parent cc38c8ec00
commit b15175b05b
2 changed files with 5 additions and 5 deletions

View File

@ -27,6 +27,7 @@
#include <fstream>
#include <unistd.h>
#include <ini.h>
#include <cassert>
#ifdef HAVE_LIBOPK
#include <opk.h>
@ -396,8 +397,8 @@ void Menu::setSectionIndex(int i) {
/*====================================
LINKS MANAGEMENT
====================================*/
bool Menu::addActionLink(uint section, const string &title, function_t action, const string &description, const string &icon) {
if (section>=sections.size()) return false;
void Menu::addActionLink(uint section, const string &title, function_t action, const string &description, const string &icon) {
assert(section < sections.size());
Link *link = new Link(gmenu2x, action);
link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
@ -410,8 +411,7 @@ bool Menu::addActionLink(uint section, const string &title, function_t action, c
link->setIcon(icon);
}
sectionLinks(section)->push_back(link);
return true;
links[section].push_back(link);
}
bool Menu::addLink(string path, string file, string section) {

View File

@ -113,7 +113,7 @@ public:
const std::string &selSection();
void setSectionIndex(int i);
bool addActionLink(uint section, const std::string &title,
void addActionLink(uint section, const std::string &title,
function_t action, const std::string &description="",
const std::string &icon="");
bool addLink(std::string path, std::string file, std::string section="");