It is now impossible to open or clone a view that is not finished (= has
been closed at least once)
This commit is contained in:
@ -1169,7 +1169,7 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
|
|||||||
}
|
}
|
||||||
|
|
||||||
view->dms = dms;
|
view->dms = dms;
|
||||||
view->read_only = 0;
|
view->read_only = false;
|
||||||
|
|
||||||
// Create view file
|
// Create view file
|
||||||
if (create_obiview_file(dms, view_name) < 0)
|
if (create_obiview_file(dms, view_name) < 0)
|
||||||
@ -1187,16 +1187,19 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flag the view as being a work in progress
|
||||||
|
(view->infos)->finished = false;
|
||||||
|
|
||||||
// Write used size in view file for initial structure
|
// Write used size in view file for initial structure
|
||||||
(view->infos)->used_size = sizeof(Obiview_infos_t);
|
(view->infos)->used_size = sizeof(Obiview_infos_t);
|
||||||
|
|
||||||
// Clone view to clone if there is one
|
// Clone view to clone if there is one
|
||||||
if (view_to_clone != NULL)
|
if (view_to_clone != NULL)
|
||||||
{
|
{
|
||||||
if (!(view_to_clone->read_only))
|
if ((view_to_clone->infos)->finished == false)
|
||||||
{
|
{
|
||||||
obi_set_errno(OBIVIEW_ERROR);
|
obi_set_errno(OBIVIEW_ERROR);
|
||||||
obidebug(1, "\nA view can not be cloned if it is not read-only");
|
obidebug(1, "\nA view can not be cloned if it is not finished");
|
||||||
obi_view_unmap_file(view->dms, view->infos);
|
obi_view_unmap_file(view->dms, view->infos);
|
||||||
free(view);
|
free(view);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1634,6 +1637,15 @@ Obiview_p obi_open_view(OBIDMS_p dms, const char* view_name)
|
|||||||
// Map view file
|
// Map view file
|
||||||
view->infos = obi_view_map_file(dms, view_name);
|
view->infos = obi_view_map_file(dms, view_name);
|
||||||
|
|
||||||
|
// Check that the view is finished and can be opened
|
||||||
|
if ((view->infos)->finished == false)
|
||||||
|
{
|
||||||
|
obidebug(1, "\nError opening a view: the view is not finished");
|
||||||
|
obi_view_unmap_file(view->dms, view->infos);
|
||||||
|
free(view);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Open the line selection associated with the view
|
// Open the line selection associated with the view
|
||||||
if ((view->infos)->all_lines)
|
if ((view->infos)->all_lines)
|
||||||
view->line_selection = NULL;
|
view->line_selection = NULL;
|
||||||
@ -1983,6 +1995,9 @@ int obi_close_view(Obiview_p view)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flag the view as finished
|
||||||
|
(view->infos)->finished = true;
|
||||||
|
|
||||||
// Free the column dictionary
|
// Free the column dictionary
|
||||||
ht_free(view->column_dict);
|
ht_free(view->column_dict);
|
||||||
|
|
||||||
|
@ -94,6 +94,8 @@ typedef struct Obiview_infos {
|
|||||||
*/
|
*/
|
||||||
Alias_column_pair_t column_references[MAX_NB_OPENED_COLUMNS]; /**< References (name, version and alias) for all the columns in the view.
|
Alias_column_pair_t column_references[MAX_NB_OPENED_COLUMNS]; /**< References (name, version and alias) for all the columns in the view.
|
||||||
*/
|
*/
|
||||||
|
bool finished; /** Whether the view is finished and can be read.
|
||||||
|
*/
|
||||||
char comments[]; /**< Comments, additional informations on the view.
|
char comments[]; /**< Comments, additional informations on the view.
|
||||||
*/
|
*/
|
||||||
} Obiview_infos_t, *Obiview_infos_p;
|
} Obiview_infos_t, *Obiview_infos_p;
|
||||||
|
Reference in New Issue
Block a user