Fix a bug in palette that kept it from being idempotent.
This commit is contained in:
parent
986b2612d4
commit
37b007d79c
5 changed files with 21 additions and 10 deletions
22
palette.cpp
22
palette.cpp
|
|
@ -16,6 +16,10 @@ namespace palette {
|
|||
|
||||
static PaletteMgr COLOR;
|
||||
|
||||
bool initialized() {
|
||||
return COLOR.initialized;
|
||||
}
|
||||
|
||||
void init(const string &json_file) {
|
||||
if(!COLOR.initialized) {
|
||||
COLOR.initialized = true;
|
||||
|
|
@ -41,18 +45,18 @@ namespace palette {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(auto [color_path, ref] : COLOR.pending_refs) {
|
||||
dbc::check(COLOR.palettes.contains(ref),
|
||||
fmt::format("In {} you have {} referring to {} but {} doesn't exist.",
|
||||
COLOR.config, color_path, ref, ref));
|
||||
dbc::check(!COLOR.palettes.contains(color_path),
|
||||
fmt::format("Color {} with ref {} is duplicated.", color_path, ref));
|
||||
for(auto [color_path, ref] : COLOR.pending_refs) {
|
||||
dbc::check(COLOR.palettes.contains(ref),
|
||||
fmt::format("In {} you have {} referring to {} but {} doesn't exist.",
|
||||
COLOR.config, color_path, ref, ref));
|
||||
dbc::check(!COLOR.palettes.contains(color_path),
|
||||
fmt::format("Color {} with ref {} is duplicated.", color_path, ref));
|
||||
|
||||
auto color = COLOR.palettes.at(ref);
|
||||
auto color = COLOR.palettes.at(ref);
|
||||
|
||||
COLOR.palettes.try_emplace(color_path, color);
|
||||
COLOR.palettes.try_emplace(color_path, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue