TM: Don't allow passing NULL to tm_workspace API
This commit is contained in:
parent
0ed236db30
commit
6a0673f4ae
@ -501,10 +501,13 @@ static gboolean handle_save_as(const gchar *utf8_filename, gboolean rename_file)
|
|||||||
{
|
{
|
||||||
document_rename_file(doc, utf8_filename);
|
document_rename_file(doc, utf8_filename);
|
||||||
}
|
}
|
||||||
/* create a new tm_source_file object otherwise tagmanager won't work correctly */
|
if (doc->tm_file)
|
||||||
tm_workspace_remove_source_file(doc->tm_file);
|
{
|
||||||
tm_source_file_free(doc->tm_file);
|
/* create a new tm_source_file object otherwise tagmanager won't work correctly */
|
||||||
doc->tm_file = NULL;
|
tm_workspace_remove_source_file(doc->tm_file);
|
||||||
|
tm_source_file_free(doc->tm_file);
|
||||||
|
doc->tm_file = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
success = document_save_file_as(doc, utf8_filename);
|
success = document_save_file_as(doc, utf8_filename);
|
||||||
|
|
||||||
|
@ -714,8 +714,11 @@ static gboolean remove_page(guint page_num)
|
|||||||
g_free(doc->priv->saved_encoding.encoding);
|
g_free(doc->priv->saved_encoding.encoding);
|
||||||
g_free(doc->file_name);
|
g_free(doc->file_name);
|
||||||
g_free(doc->real_path);
|
g_free(doc->real_path);
|
||||||
tm_workspace_remove_source_file(doc->tm_file);
|
if (doc->tm_file)
|
||||||
tm_source_file_free(doc->tm_file);
|
{
|
||||||
|
tm_workspace_remove_source_file(doc->tm_file);
|
||||||
|
tm_source_file_free(doc->tm_file);
|
||||||
|
}
|
||||||
|
|
||||||
if (doc->priv->tag_tree)
|
if (doc->priv->tag_tree)
|
||||||
gtk_widget_destroy(doc->priv->tag_tree);
|
gtk_widget_destroy(doc->priv->tag_tree);
|
||||||
|
@ -202,9 +202,8 @@ void tm_workspace_update_source_file_buffer(TMSourceFile *source_file, guchar* t
|
|||||||
void tm_workspace_remove_source_file(TMSourceFile *source_file)
|
void tm_workspace_remove_source_file(TMSourceFile *source_file)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
if (!source_file)
|
g_return_if_fail(source_file != NULL);
|
||||||
return;
|
|
||||||
|
|
||||||
for (i=0; i < theWorkspace->source_files->len; ++i)
|
for (i=0; i < theWorkspace->source_files->len; ++i)
|
||||||
{
|
{
|
||||||
@ -270,7 +269,9 @@ static void tm_workspace_update(void)
|
|||||||
void tm_workspace_add_source_files(GPtrArray *source_files)
|
void tm_workspace_add_source_files(GPtrArray *source_files)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
|
g_return_if_fail(source_files != NULL);
|
||||||
|
|
||||||
for (i = 0; i < source_files->len; i++)
|
for (i = 0; i < source_files->len; i++)
|
||||||
{
|
{
|
||||||
TMSourceFile *source_file = source_files->pdata[i];
|
TMSourceFile *source_file = source_files->pdata[i];
|
||||||
@ -292,7 +293,9 @@ void tm_workspace_add_source_files(GPtrArray *source_files)
|
|||||||
void tm_workspace_remove_source_files(GPtrArray *source_files)
|
void tm_workspace_remove_source_files(GPtrArray *source_files)
|
||||||
{
|
{
|
||||||
guint i, j;
|
guint i, j;
|
||||||
|
|
||||||
|
g_return_if_fail(source_files != NULL);
|
||||||
|
|
||||||
//TODO: sort both arrays by pointer value and remove in single pass
|
//TODO: sort both arrays by pointer value and remove in single pass
|
||||||
for (i = 0; i < source_files->len; i++)
|
for (i = 0; i < source_files->len; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user