mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
don't add invalid keywords (empty match) to database.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@277 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -170,7 +170,11 @@ void Keyword::prepare(const vector<KeywordParamP>& param_types, bool force) {
|
||||
}
|
||||
}
|
||||
regex += _(")");
|
||||
if (!matchRe.Compile(regex, wxRE_ADVANCED)) {
|
||||
if (matchRe.Compile(regex, wxRE_ADVANCED)) {
|
||||
// not valid if it matches "", that would make MSE hang
|
||||
valid = !matchRe.Matches(_(""));
|
||||
} else {
|
||||
valid = false;
|
||||
throw InternalError(_("Error creating match regex"));
|
||||
}
|
||||
}
|
||||
@@ -254,7 +258,7 @@ void KeywordDatabase::add(const vector<KeywordP>& kws) {
|
||||
}
|
||||
|
||||
void KeywordDatabase::add(const Keyword& kw) {
|
||||
if (kw.match.empty()) return; // can't handle empty keywords
|
||||
if (kw.match.empty() || !kw.valid) return; // can't handle empty keywords
|
||||
if (!root) {
|
||||
root = new KeywordTrie;
|
||||
root->on_any_star = root;
|
||||
|
||||
@@ -65,7 +65,7 @@ class KeywordMode {
|
||||
/// A keyword for a set or a game
|
||||
class Keyword {
|
||||
public:
|
||||
Keyword() : fixed(false) {}
|
||||
Keyword() : fixed(false), valid(false) {}
|
||||
|
||||
String keyword; ///< The keyword, only for human use
|
||||
String rules; ///< Rules/explanation
|
||||
|
||||
Reference in New Issue
Block a user