FIX: skip the color codes with undefined color syntax

jira: [STUDIO-13037]
Change-Id: Ic733a2b67df49556c16f4392ecf61d95471e9aa8
(cherry picked from commit 6658f522166e432b383669903a0b30ee15cf6cdc)
This commit is contained in:
xin.zhang
2025-06-30 20:11:04 +08:00
committed by Noisyfox
parent e3cb884ee8
commit 025294894a
2 changed files with 15 additions and 1 deletions

View File

@@ -81,8 +81,17 @@ void FilamentColorCodeQuery::LoadFromLocal()
if (json_data_item.contains("fila_color"))
{
const auto& fila_color_strs = json_data_item["fila_color"].get<std::vector<wxString>>();
for (const auto& color_str : fila_color_strs) { fila_color.m_colors.emplace(wxColour(color_str)); }
for (const auto& color_str : fila_color_strs) {
if (color_str.size() > 3) /* Skip the value like "#0"*/{
fila_color.m_colors.emplace(wxColour(color_str));
}
}
}
if (fila_color.m_colors.empty()) {
BOOST_LOG_TRIVIAL(warning) << "FilamentColorCodeQuery::LoadFromLocal: No colors found for fila_color_code: " << fila_color_code;
continue; // Skip if no colors are defined
};
const wxString& fila_color_type = json_data_item.contains("fila_color_type") ? wxString::FromUTF8(json_data_item["fila_color_type"].get<std::string>()) : wxString();
if (fila_color_type == wxString::FromUTF8("单色")) {

View File

@@ -64,6 +64,7 @@ struct wxColorSorter
if (ha.h != hb.h) return ha.h < hb.h;
if (ha.s != hb.s) return ha.s < hb.s;
if (ha.v != hb.v) return ha.v < hb.v;
if (lhs_it.Alpha() != rhs_it.Alpha()) return lhs_it.Alpha() < rhs_it.Alpha();
return false;
}
};
@@ -119,6 +120,10 @@ public:
if (ha.s != hb.s) return ha.s < hb.s;
if (ha.v != hb.v) return ha.v < hb.v;
int lhs_alpha = lhs_it->Alpha();
int rhs_alpha = rhs_it->Alpha();
if (lhs_alpha != rhs_alpha) return lhs_alpha < rhs_alpha;
lhs_it++;
rhs_it++;
}