mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[Card] Bind search language per FilterString instance
The peg parser rules are set up once per process, so the GenericQuery and OracleQuery rule actions could not capture per-instance state. Instead of storing the search language in a process-global that FilterString instance methods mutate, hand it to the rule actions through a thread-local parse context and copy it into the filter closures they produce. Card evaluation in FilterString::check no longer reads any process-global state, and each instance keeps the language it was built with; constructing one instance no longer changes what unrelated instances (deck filter, drop-to-hand, zone views) match against. The card database display model stores the raw query and rebuilds the FilterString when the search language changes, since the language is now bound at parse time. Add tests for the English/Selected/Both search modes, the English fallback for untranslated cards, and per-instance language independence.
This commit is contained in:
parent
e029173e29
commit
14cf4ee2a9
5 changed files with 81 additions and 33 deletions
|
|
@ -239,9 +239,9 @@ void CardDatabaseDisplayModel::setFilterTree(FilterTree *_filterTree)
|
|||
|
||||
void CardDatabaseDisplayModel::setStringFilter(const QString &_src)
|
||||
{
|
||||
searchText = _src;
|
||||
delete filterString;
|
||||
filterString = new FilterString(_src);
|
||||
filterString->setSearchLanguage(searchLanguage, searchLanguageMode);
|
||||
filterString = new FilterString(_src, searchLanguage, searchLanguageMode);
|
||||
dirty();
|
||||
}
|
||||
|
||||
|
|
@ -255,7 +255,7 @@ void CardDatabaseDisplayModel::setSearchLanguage(const QString &searchLang, Card
|
|||
searchLanguageMode = mode;
|
||||
|
||||
if (filterString != nullptr) {
|
||||
filterString->setSearchLanguage(searchLanguage, searchLanguageMode);
|
||||
setStringFilter(searchText);
|
||||
}
|
||||
dirty();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue