Fixed bug when closing views with no associated predicate

This commit is contained in:
Celine Mercier
2016-08-12 15:52:38 +02:00
parent 64a745ce0b
commit 92cad61417

View File

@ -839,6 +839,13 @@ char* view_check_all_predicates(Obiview_p view)
char* all_predicates_string = NULL;
char** all_predicates = NULL;
if (view->nb_predicates == 0)
{
obi_set_errno(OBIVIEW_ERROR);
obidebug(1, "\nError trying to check predicates of a view with no predicates.");
return NULL;
}
size_to_allocate = 0;
// Allocate memory for predicate array
@ -1771,14 +1778,17 @@ int obi_save_and_close_view(Obiview_p view)
if (!(view->read_only))
{
predicates = view_check_all_predicates(view);
if (predicates == NULL)
return -1; // TODO reverse view (delete files)
else
if (view->nb_predicates > 0)
{
// TODO check size and grow file if needed
strcat((view->infos)->comments, predicates);
free(predicates);
predicates = view_check_all_predicates(view);
if (predicates == NULL)
return -1; // TODO reverse view (delete files)
else
{
// TODO check size and grow file if needed
strcat((view->infos)->comments, predicates);
free(predicates);
}
}
if (obi_save_view(view) < 0)
return -1;