Don't allow setting invalid or unknown language

This commit is contained in:
Slava Monich 2015-07-03 01:01:05 +03:00
parent fd0852a60d
commit c9419843cc

View file

@ -238,13 +238,11 @@ void Book::setTitle(const std::string &title) {
} }
void Book::setLanguage(const std::string &language) { void Book::setLanguage(const std::string &language) {
if (!myLanguage.empty()) { if (!language.empty()) {
const std::vector<std::string> &codes = ZLLanguageList::languageCodes(); const std::vector<std::string> &codes = ZLLanguageList::languageCodes();
std::vector<std::string>::const_iterator it = std::vector<std::string>::const_iterator it =
std::find(codes.begin(), codes.end(), myLanguage);
std::vector<std::string>::const_iterator jt =
std::find(codes.begin(), codes.end(), language); std::find(codes.begin(), codes.end(), language);
if (it != codes.end() && jt == codes.end()) { if (it == codes.end()) {
return; return;
} }
} }