Skip to content

Commit

Permalink
vkconfig3: Fix duplicated settings and presets when reloading layers
Browse files Browse the repository at this point in the history
Change-Id: I80ab616edd4d267106e1ebcc896e228bc6ce515e
  • Loading branch information
christophe-lunarg committed Jan 6, 2025
1 parent e89b658 commit ce3d0ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions vkconfig_core/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,14 @@ LayerLoadStatus Layer::Load(const Path& full_path_to_file, LayerType type, bool
const QJsonObject& json_features_object = json_features_value.toObject();

// Load layer settings
this->settings.clear();
const QJsonValue& json_settings_value = json_features_object.value("settings");
if (json_settings_value != QJsonValue::Undefined) {
AddSettingsSet(this->settings, nullptr, json_settings_value);
}

// Load layer presets
this->presets.clear();
const QJsonValue& json_presets_value = json_features_object.value("presets");
if (json_presets_value != QJsonValue::Undefined) {
assert(json_presets_value.isArray());
Expand Down
9 changes: 9 additions & 0 deletions vkconfig_core/test/test_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ TEST(test_layer, load_preset_interit) {
EXPECT_STREQ("Preset Override", layer.presets[1].label.c_str());
EXPECT_EQ(PLATFORM_WINDOWS_BIT | PLATFORM_MACOS_BIT, layer.presets[1].platform_flags);
EXPECT_EQ(STATUS_ALPHA, layer.presets[1].status);

const LayerLoadStatus reloaded = layer.Load(":/layers/VK_LAYER_LUNARG_test_04.json", LAYER_TYPE_EXPLICIT, false, Dummy());
EXPECT_EQ(reloaded, LAYER_LOAD_ADDED);
EXPECT_EQ(1, layer.settings.size());
EXPECT_EQ(2, layer.presets.size());
}

TEST(test_layer, load_setting_children_interit) {
Expand Down Expand Up @@ -231,6 +236,10 @@ TEST(test_layer, load_setting_missing) {

LayerControl layer_controlA = layer.GetActualControl();
EXPECT_EQ(layer_controlA, LAYER_CONTROL_ON);

const LayerLoadStatus reloaded = layer.Load(":/layers/VK_LAYER_LUNARG_test_07.json", LAYER_TYPE_IMPLICIT, false, Dummy());
EXPECT_EQ(1, layer.settings.size());
EXPECT_EQ(1, layer.presets.size());
}

TEST(test_layer, load_env_variable) {
Expand Down

0 comments on commit ce3d0ae

Please sign in to comment.