Unverified Commit d07e354f authored by Murray Cumming's avatar Murray Cumming
Browse files

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 ae4fa610
...@@ -724,7 +724,7 @@ void Document::remove_field(const Glib::ustring& table_name, const Glib::ustring ...@@ -724,7 +724,7 @@ void Document::remove_field(const Glib::ustring& table_name, const Glib::ustring
const auto table_info = get_table_info(table_name); const auto table_info = get_table_info(table_name);
if(table_info) if(table_info)
{ {
auto vecFields = table_info->m_fields; auto& vecFields = table_info->m_fields;
auto iterFind = find_if_same_name(vecFields, field_name); auto iterFind = find_if_same_name(vecFields, field_name);
if(iterFind != vecFields.end()) //If it was found: if(iterFind != vecFields.end()) //If it was found:
{ {
......
...@@ -169,12 +169,21 @@ int main() ...@@ -169,12 +169,21 @@ int main()
//Remove a field from the whole document: //Remove a field from the whole document:
document.remove_field("publisher", "publisher_id"); 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")) 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." << std::endl; std::cerr << G_STRFUNC << ": Failure: The removed field name is still used on a layout." << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
//Remove a relationship: //Remove a relationship:
document.remove_relationship(relationship); document.remove_relationship(relationship);
relationship = document.get_relationship("invoice_lines", "products"); relationship = document.get_relationship("invoice_lines", "products");
...@@ -183,7 +192,7 @@ int main() ...@@ -183,7 +192,7 @@ int main()
std::cerr << G_STRFUNC << ": Failure: The removed relationship still exists." << std::endl; std::cerr << G_STRFUNC << ": Failure: The removed relationship still exists." << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
//Change a table name: //Change a table name:
const Glib::ustring table_renamed = "invoiceslinesrenamed"; const Glib::ustring table_renamed = "invoiceslinesrenamed";
document.change_table_name("invoice_lines", table_renamed); document.change_table_name("invoice_lines", table_renamed);
......
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