You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
YList functionality fails when list entity key values initialized after the element is added to the list.
Root cause
It is happening because by the time of appending to the list the key values are not yet set. That causes the entity to be stored in the YList map with wrong key value.
Steps to Reproduce
Run this C++ test:
TEST_CASE("test_ylist_race")
{
TestEntity* list_holder = new TestEntity();
YList ylist = YList(list_holder, {"name"});
// Append test1 to the YList before key value is defined
auto test1 = std::make_shared<TestEntity>();
ylist.append(test1);
test1->name = "test1";
test1->enabled = true;
auto keys = ylist.keys();
REQUIRE(vector_to_string(keys) == R"("test1")");
auto ep = ylist["test1"];
REQUIRE(ep != nullptr);
}
Solution for this issue should be similar to the one applied in Python (append entities to cache, then flush the cache to YList map before accessing it), but it breaks 'const' qualifier in multiple Entity class functions in the generated bundle code. That will affect lots of core and generated code. Hence postponing the resolution of this bug to the next release.
Current Behavior
YList functionality fails when list entity key values initialized after the element is added to the list.
Root cause
It is happening because by the time of appending to the list the key values are not yet set. That causes the entity to be stored in the YList map with wrong key value.
Steps to Reproduce
Run this C++ test:
The test fails with message:
Expected Behavior
The test should pass as long as list element keys are initialized before any access to the list.
System Information
YDK0.7.2
The text was updated successfully, but these errors were encountered: