Skip to content

Commit

Permalink
fix minor bugs in treeSeqMetadata()
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaller committed Jan 17, 2025
1 parent b0a0e53 commit 68f34e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ development head (in the master branch):
add recipe 15.22, "Complex multi-chromosome inheritance with addMultiRecombinant()", to illustrate addMultiRecombinant()
modified recipes 15.14 and 15.21 to illustrate that NULL can now be passed to addRecombinant() for breaks to get automatic breakpoint generation
cleaned up the confusion around Dictionary vs. DictionaryBase; methods/functions can now use Dictionary in their signature without problems
fix a bug in treeSeqMetadata(); if no metadata was found, it would return object<Dictionary>(0), not an empty Dictionary object (and it leaked)


version 4.3 (Eidos version 3.3):
Expand Down
9 changes: 7 additions & 2 deletions core/slim_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1963,8 +1963,12 @@ EidosValue_SP SLiM_ExecuteFunction_treeSeqMetadata(const std::vector<EidosValue_
{
tsk_table_collection_free(&temp_tables);

// With no metadata, return an empty dictionary
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosDictionaryRetained_Class));
// With no metadata, return an empty dictionary. BCH 1/17/2025: prior to SLiM 5, this erroneously returned object<Dictionary>(0)
EidosDictionaryRetained *objectElement = new EidosDictionaryRetained();
EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDictionaryRetained_Class));

objectElement->Release(); // retained by result_SP
return result_SP;
}

std::string metadata_schema_string(temp_tables.metadata_schema, temp_tables.metadata_schema_length);
Expand Down Expand Up @@ -2015,6 +2019,7 @@ EidosValue_SP SLiM_ExecuteFunction_treeSeqMetadata(const std::vector<EidosValue_
EidosDictionaryRetained *objectElement = new EidosDictionaryRetained();
EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDictionaryRetained_Class));

objectElement->Release(); // retained by result_SP
objectElement->AddJSONFrom(metadata);
objectElement->ContentsChanged("treeSeqMetadata()");
return result_SP;
Expand Down

0 comments on commit 68f34e9

Please sign in to comment.