From 84a987e9d52d14f308f15a02ca5a5059b86ae9c2 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Fri, 19 Jul 2013 12:50:20 -0400 Subject: [PATCH] When loading multiple OPKs, don't order links each time one is added --- src/menu.cpp | 12 ++++++++---- src/menu.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/menu.cpp b/src/menu.cpp index 51c6e47..d44fb75 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -458,7 +458,7 @@ void Menu::openPackagesFromDir(std::string path) #endif } -void Menu::openPackage(std::string path) +void Menu::openPackage(std::string path, bool order) { /* First try to remove existing links of the same OPK * (needed for instance when an OPK is modified) */ @@ -516,7 +516,9 @@ void Menu::openPackage(std::string path) } opk_close(opk); - orderLinks(); + + if (order) + orderLinks(); } void Menu::readPackages(std::string parentDir) @@ -548,10 +550,11 @@ void Menu::readPackages(std::string parentDir) continue; } - openPackage(parentDir + '/' + dptr->d_name); + openPackage(parentDir + '/' + dptr->d_name, false); } closedir(dirp); + orderLinks(); } #ifdef ENABLE_INOTIFY @@ -608,7 +611,8 @@ void Menu::orderLinks() { for (std::vector< std::vector >::iterator section = links.begin(); section < links.end(); section++) - std::sort(section->begin(), section->end(), compare_links); + if (section->size() > 1) + std::sort(section->begin(), section->end(), compare_links); } void Menu::readLinks() { diff --git a/src/menu.h b/src/menu.h index 7c1c649..ab3c0ac 100644 --- a/src/menu.h +++ b/src/menu.h @@ -67,7 +67,7 @@ public: ~Menu(); #ifdef HAVE_LIBOPK - void openPackage(std::string path); + void openPackage(std::string path, bool order = true); void openPackagesFromDir(std::string path); #ifdef ENABLE_INOTIFY void removePackageLink(std::string path);