Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #1799 (Can't set cell properties by script) #1800

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/db/db/dbPropertiesRepository.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ PropertiesRepository::prop_name_id (const tl::Variant &name)
void
PropertiesRepository::change_properties (property_names_id_type id, const properties_set &new_props)
{
// NOTE: change_properties MAY put the property map into a state where there is
// more than one property ID per set. For example, 1 and 5 may be valid property
// ids for the same set. "properties(1)" and "properties(5)" returns the same
// property set "S", while "properties_id(S)" only returns 1.

const properties_set &old_props = properties (id);

std::map <properties_set, properties_id_type>::const_iterator pi = m_properties_ids_by_set.find (old_props);
Expand Down Expand Up @@ -149,7 +154,10 @@ PropertiesRepository::properties_id (const properties_set &props)
std::map <properties_set, properties_id_type>::const_iterator pi = m_properties_ids_by_set.find (props);
if (pi == m_properties_ids_by_set.end ()) {

properties_id_type id = m_properties_ids_by_set.size ();
properties_id_type id = 0;
if (! m_properties_by_id.empty ()) {
id = (--m_properties_by_id.end ())->first + 1;
}
m_properties_ids_by_set.insert (std::make_pair (props, id));
m_properties_by_id.insert (std::make_pair (id, props));
for (properties_set::const_iterator nv = props.begin (); nv != props.end (); ++nv) {
Expand Down
25 changes: 25 additions & 0 deletions src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,31 @@ TEST(Bug_1474)
}
}

TEST(Bug_1799)
{
db::Manager m (false);
db::Layout layout (&m);

{
tl::InputStream file (tl::testdata () + "/oasis/issue_1799.oas");
db::OASISReader reader (file);
reader.read (layout);
}

db::properties_id_type pn = layout.properties_repository ().prop_name_id (tl::Variant (1));
db::PropertiesRepository::properties_set ps;
ps.insert (std::make_pair (pn, tl::Variant ("hello, world!")));

auto pid = layout.properties_repository ().properties_id (ps);

auto ps2 = layout.properties_repository ().properties (pid);
EXPECT_EQ (ps2.size (), size_t (1));
EXPECT_EQ (ps2.find (pn) != ps2.end (), true);
if (ps2.find (pn) != ps2.end ()) {
EXPECT_EQ (ps2.find (pn)->second.to_string (), "hello, world!");
}
}

TEST(DuplicateCellname)
{
db::Manager m (false);
Expand Down
Binary file added testdata/oasis/issue_1799.oas
Binary file not shown.
Loading