Bug #3168: process attributes in update --append

This commit is contained in:
Carlos Martín committed 2014-10-20 16:15:06 +02:00
1 parent 2669f57e98
commit 930c13ae76
8 files changed
+85 -146

No files matched your search

+43 -2
View File
@@ -170,7 +170,8 @@ void PoolObjectSQL::clear_template_error_message()
int PoolObjectSQL::replace_template(
const string& tmpl_str, bool keep_restricted, string& error)
{
Template * new_tmpl = get_new_template();
Template * old_tmpl = 0;
Template * new_tmpl = get_new_template();
if ( new_tmpl == 0 )
{
@@ -184,6 +185,11 @@ int PoolObjectSQL::replace_template(
return -1;
}
if (obj_template != 0)
{
old_tmpl = new Template(*obj_template);
}
if (keep_restricted && new_tmpl->has_restricted())
{
new_tmpl->remove_restricted();
@@ -201,6 +207,22 @@ int PoolObjectSQL::replace_template(
obj_template = new_tmpl;
if (post_update_template(error) == -1)
{
delete obj_template;
if (old_tmpl != 0)
{
obj_template = old_tmpl;
}
else
{
obj_template = 0;
}
return -1;
}
return 0;
}
@@ -210,7 +232,8 @@ int PoolObjectSQL::replace_template(
int PoolObjectSQL::append_template(
const string& tmpl_str, bool keep_restricted, string& error)
{
Template * new_tmpl = get_new_template();
Template * old_tmpl = 0;
Template * new_tmpl = get_new_template();
if ( new_tmpl == 0 )
{
@@ -231,6 +254,8 @@ int PoolObjectSQL::append_template(
if ( obj_template != 0 )
{
old_tmpl = new Template(*obj_template);
obj_template->merge(new_tmpl, error);
delete new_tmpl;
}
@@ -239,6 +264,22 @@ int PoolObjectSQL::append_template(
obj_template = new_tmpl;
}
if (post_update_template(error) == -1)
{
delete obj_template;
if (old_tmpl != 0)
{
obj_template = old_tmpl;
}
else
{
obj_template = 0;
}
return -1;
}
return 0;
}