Fixed bug when closing views with no associated predicate
This commit is contained in:
@ -839,6 +839,13 @@ char* view_check_all_predicates(Obiview_p view)
|
|||||||
char* all_predicates_string = NULL;
|
char* all_predicates_string = NULL;
|
||||||
char** all_predicates = 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;
|
size_to_allocate = 0;
|
||||||
|
|
||||||
// Allocate memory for predicate array
|
// Allocate memory for predicate array
|
||||||
@ -1771,14 +1778,17 @@ int obi_save_and_close_view(Obiview_p view)
|
|||||||
|
|
||||||
if (!(view->read_only))
|
if (!(view->read_only))
|
||||||
{
|
{
|
||||||
predicates = view_check_all_predicates(view);
|
if (view->nb_predicates > 0)
|
||||||
if (predicates == NULL)
|
|
||||||
return -1; // TODO reverse view (delete files)
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// TODO check size and grow file if needed
|
predicates = view_check_all_predicates(view);
|
||||||
strcat((view->infos)->comments, predicates);
|
if (predicates == NULL)
|
||||||
free(predicates);
|
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)
|
if (obi_save_view(view) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
Reference in New Issue
Block a user