Date:2013-08-12 00:08:28 (4 years 11 months ago)
Author:Maarten ter Huurne
Commit:271ef00c18bf173556a561148d4e68ba4b9f2f42
Message:Call Menu::selLinkApp() only once in GMenu2X::editLink()

Files: src/gmenu2x.cpp (4 diffs)

Change Details

src/gmenu2x.cpp
855855}
856856
857857void GMenu2X::editLink() {
858    if (menu->selLinkApp()==NULL) return;
858    LinkApp *linkApp = menu->selLinkApp();
859    if (!linkApp) return;
859860
860861    vector<string> pathV;
861    split(pathV,menu->selLinkApp()->getFile(),"/");
862    split(pathV,linkApp->getFile(),"/");
862863    string oldSection = "";
863864    if (pathV.size()>1)
864865        oldSection = pathV[pathV.size()-2];
865866    string newSection = oldSection;
866867
867    string linkTitle = menu->selLinkApp()->getTitle();
868    string linkDescription = menu->selLinkApp()->getDescription();
869    string linkIcon = menu->selLinkApp()->getIcon();
870    string linkManual = menu->selLinkApp()->getManual();
871    string linkSelFilter = menu->selLinkApp()->getSelectorFilter();
872    string linkSelDir = menu->selLinkApp()->getSelectorDir();
873    bool linkSelBrowser = menu->selLinkApp()->getSelectorBrowser();
874    string linkSelScreens = menu->selLinkApp()->getSelectorScreens();
875    string linkSelAliases = menu->selLinkApp()->getAliasFile();
876    int linkClock = menu->selLinkApp()->clock();
868    string linkTitle = linkApp->getTitle();
869    string linkDescription = linkApp->getDescription();
870    string linkIcon = linkApp->getIcon();
871    string linkManual = linkApp->getManual();
872    string linkSelFilter = linkApp->getSelectorFilter();
873    string linkSelDir = linkApp->getSelectorDir();
874    bool linkSelBrowser = linkApp->getSelectorBrowser();
875    string linkSelScreens = linkApp->getSelectorScreens();
876    string linkSelAliases = linkApp->getAliasFile();
877    int linkClock = linkApp->clock();
877878
878879    string diagTitle = tr.translate("Edit link: $1",linkTitle.c_str(),NULL);
879    string diagIcon = menu->selLinkApp()->getIconPath();
880    string diagIcon = linkApp->getIconPath();
880881
881882    SettingsDialog sd(this, input, ts, diagTitle, diagIcon);
882883#ifdef HAVE_LIBOPK
883    if (!menu->selLinkApp()->isOpk()) {
884    if (!linkApp->isOpk()) {
884885#endif
885886    sd.addSetting(new MenuSettingString(this, ts, tr["Title"], tr["Link title"], &linkTitle, diagTitle, diagIcon));
886887    sd.addSetting(new MenuSettingString(this, ts, tr["Description"], tr["Link description"], &linkDescription, diagTitle, diagIcon));
...... 
893894                    &linkManual, "man.png,txt"));
894895#ifdef HAVE_LIBOPK
895896    }
896    if (!menu->selLinkApp()->isOpk() ||
897                !menu->selLinkApp()->getSelectorDir().empty()) {
897    if (!linkApp->isOpk() || !linkApp->getSelectorDir().empty()) {
898898#endif
899899    sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Directory"], tr["Directory to scan for the selector"], &linkSelDir));
900900    sd.addSetting(new MenuSettingBool(this, ts, tr["Selector Browser"], tr["Allow the selector to change directory"], &linkSelBrowser));
...... 
905905    sd.addSetting(new MenuSettingInt(this, ts, tr["Clock frequency"], tr["Cpu clock frequency to set when launching this link"], &linkClock, cpuFreqMin, confInt["maxClock"], cpuFreqMultiple));
906906#endif
907907#ifdef HAVE_LIBOPK
908    if (!menu->selLinkApp()->isOpk()) {
908    if (!linkApp->isOpk()) {
909909#endif
910910    sd.addSetting(new MenuSettingString(this, ts, tr["Selector Filter"], tr["Selector filter (Separate values with a comma)"], &linkSelFilter, diagTitle, diagIcon));
911911    sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Screenshots"], tr["Directory of the screenshots for the selector"], &linkSelScreens));
912912    sd.addSetting(new MenuSettingFile(this, ts, tr["Selector Aliases"], tr["File containing a list of aliases for the selector"], &linkSelAliases));
913    sd.addSetting(new MenuSettingBool(this, ts, tr["Don't Leave"], tr["Don't quit GMenu2X when launching this link"], &menu->selLinkApp()->runsInBackgroundRef()));
913    sd.addSetting(new MenuSettingBool(this, ts, tr["Don't Leave"], tr["Don't quit GMenu2X when launching this link"], &linkApp->runsInBackgroundRef()));
914914#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
915    sd.addSetting(new MenuSettingBool(this, ts, tr["Display Console"], tr["Must be enabled for console-based applications"], &menu->selLinkApp()->consoleApp));
915    sd.addSetting(new MenuSettingBool(this, ts, tr["Display Console"], tr["Must be enabled for console-based applications"], &linkApp->consoleApp));
916916#endif
917917#ifdef HAVE_LIBOPK
918918    }
919919#endif
920920
921921    if (sd.exec() && sd.edited()) {
922        menu->selLinkApp()->setTitle(linkTitle);
923        menu->selLinkApp()->setDescription(linkDescription);
924        menu->selLinkApp()->setIcon(linkIcon);
925        menu->selLinkApp()->setManual(linkManual);
926        menu->selLinkApp()->setSelectorFilter(linkSelFilter);
927        menu->selLinkApp()->setSelectorDir(linkSelDir);
928        menu->selLinkApp()->setSelectorBrowser(linkSelBrowser);
929        menu->selLinkApp()->setSelectorScreens(linkSelScreens);
930        menu->selLinkApp()->setAliasFile(linkSelAliases);
931        menu->selLinkApp()->setClock(linkClock);
922        linkApp->setTitle(linkTitle);
923        linkApp->setDescription(linkDescription);
924        linkApp->setIcon(linkIcon);
925        linkApp->setManual(linkManual);
926        linkApp->setSelectorFilter(linkSelFilter);
927        linkApp->setSelectorDir(linkSelDir);
928        linkApp->setSelectorBrowser(linkSelBrowser);
929        linkApp->setSelectorScreens(linkSelScreens);
930        linkApp->setAliasFile(linkSelAliases);
931        linkApp->setClock(linkClock);
932932
933933        INFO("New Section: '%s'\n", newSection.c_str());
934934
...... 
944944                newFileName = "sections/"+newSection+"/"+linkTitle+id;
945945                x++;
946946            }
947            rename(menu->selLinkApp()->getFile().c_str(),newFileName.c_str());
948            menu->selLinkApp()->renameFile(newFileName);
947            rename(linkApp->getFile().c_str(),newFileName.c_str());
948            linkApp->renameFile(newFileName);
949949
950950            INFO("New section index: %i.\n", newSectionIndex - menu->getSections().begin());
951951
952952            menu->linkChangeSection(menu->selLinkIndex(), menu->selSectionIndex(), newSectionIndex - menu->getSections().begin());
953953        }
954        menu->selLinkApp()->save();
954        linkApp->save();
955955        sync();
956956    }
957957}

Archive Download the corresponding diff file



interactive