mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-25 18:05:20 +02:00
Store Menu's Monitors in unique_ptrs
This results in a small code reduction and some ease of mind.
This commit is contained in:
parent
7134eb3778
commit
d66ca947c4
11
src/menu.cpp
11
src/menu.cpp
@ -106,11 +106,6 @@ Menu::Menu(GMenu2X *gmenu2x, Touchscreen &ts)
|
||||
|
||||
Menu::~Menu() {
|
||||
freeLinks();
|
||||
|
||||
#ifdef ENABLE_INOTIFY
|
||||
for (auto it : monitors)
|
||||
delete it;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Menu::readSections(std::string parentDir)
|
||||
@ -659,7 +654,7 @@ void Menu::openPackagesFromDir(std::string path)
|
||||
DEBUG("Opening packages from directory: %s\n", path.c_str());
|
||||
readPackages(path);
|
||||
#ifdef ENABLE_INOTIFY
|
||||
monitors.push_back(new Monitor(path.c_str()));
|
||||
monitors.emplace_back(new Monitor(path.c_str()));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -789,10 +784,8 @@ void Menu::removePackageLink(std::string path)
|
||||
}
|
||||
|
||||
/* Remove registered monitors */
|
||||
for (vector<Monitor *>::iterator it = monitors.begin();
|
||||
it < monitors.end(); it++) {
|
||||
for (auto it = monitors.begin(); it < monitors.end(); ++it) {
|
||||
if ((*it)->getPath().compare(0, path.size(), path) == 0) {
|
||||
delete (*it);
|
||||
monitors.erase(it);
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ private:
|
||||
// Load all the .opk packages of the given directory
|
||||
void readPackages(std::string parentDir);
|
||||
#ifdef ENABLE_INOTIFY
|
||||
std::vector<Monitor *> monitors;
|
||||
std::vector<std::unique_ptr<Monitor>> monitors;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user