fix: refuse a profile that belongs to another matcher

DockProfile::validate only checks whether a profile contradicts itself. It does
not know who is holding it, and it now accepts pattern 'arc' as well as 'v'.

Without a check at the matcher, a profile saying pattern: arc was accepted in
silence by the V matcher, which then went looking for two wings on a curved
surface. That reads as "it never detects" while the log says it is looking for
a V - the kind of mismatch that costs an afternoon. ArcPatternMatcher already
refused the reverse; this makes it symmetric.
This commit is contained in:
2026-08-26 20:14:49 +07:00
parent 8eb0040efa
commit a45694f625
2 changed files with 29 additions and 0 deletions

View File

@@ -203,6 +203,14 @@ bool VPatternMatcher::configure(const DockProfile& profile, std::string& error)
{
return false; // Giữ bộ cũ; một profile áp nửa vời còn tệ hơn không áp.
}
if (profile.pattern != PatternType::kV)
{
// `validate` chỉ kiểm profile có tự mâu thuẫn không, nó không biết ai đang cầm profile. Thiếu
// chỗ này thì một profile `pattern: arc` được bộ khớp chữ V nhận im lặng, rồi đi tìm hai cánh
// trên một mặt cong — dò mãi không ra, mà log thì báo là đang tìm chữ V.
error = std::string("VPatternMatcher was given pattern '") + toString(profile.pattern) + "'";
return false;
}
profile_ = profile;
return true;
}