Commit 0a93d5ac authored by Murray Cumming's avatar Murray Cumming

Document:remove_field(): Remove from the vector, not a copy.

And test this.
This regression was probably introduced by the conversion to use
auto with C++11.
parent db250e45
......@@ -717,7 +717,7 @@ void Document::remove_field(const Glib::ustring& table_name, const Glib::ustring
const auto table_info = get_table_info(table_name);
if(table_info)
{
auto vecFields = table_info->m_fields;
auto& vecFields = table_info->m_fields;
auto iterFind = find_if_same_name(vecFields, field_name);
if(iterFind != vecFields.end()) //If it was found:
{
......
......@@ -168,6 +168,15 @@ int main()
//Remove a field from the whole document:
document->remove_field("publisher", "publisher_id");
//Check that the old field name is not used.
auto field =
document->get_field("publisher", "publisher_id");
if (field) {
std::cerr << G_STRFUNC << ": Failure: The removed field name still exists.\n";
return EXIT_FAILURE;
}
if(field_is_on_a_layout(document, "publisher", "publisher_id"))
{
std::cerr << G_STRFUNC << ": Failure: The removed field name is still used on a layout.\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment