[geany/geany] 43b8ab: Only keep the minimal set of parameter in the TM API calls
Jiří Techet
git-noreply at xxxxx
Thu Oct 30 21:08:17 UTC 2014
Branch: refs/heads/master
Author: Jiří Techet <techet at gmail.com>
Committer: Jiří Techet <techet at gmail.com>
Date: Thu, 30 Oct 2014 21:08:17 UTC
Commit: 43b8ab8d236850bec929d981d05122dfabca99c7
https://github.com/geany/geany/commit/43b8ab8d236850bec929d981d05122dfabca99c7
Log Message:
-----------
Only keep the minimal set of parameter in the TM API calls
Avoid "utility" parameters like do_free for which we already have API calls
and which actually don't perform any free if the source file isn't
in TM. Clarify when to set the update_workspace parameter.
Modified Paths:
--------------
src/dialogs.c
src/document.c
src/plugindata.h
tagmanager/src/tm_workspace.c
tagmanager/src/tm_workspace.h
Modified: src/dialogs.c
3 lines changed, 2 insertions(+), 1 deletions(-)
===================================================================
@@ -502,7 +502,8 @@ static gboolean handle_save_as(const gchar *utf8_filename, gboolean rename_file)
document_rename_file(doc, utf8_filename);
}
/* create a new tm_source_file object otherwise tagmanager won't work correctly */
- tm_workspace_remove_source_file(doc->tm_file, TRUE, TRUE);
+ tm_workspace_remove_source_file(doc->tm_file, TRUE);
+ tm_source_file_free(doc->tm_file);
doc->tm_file = NULL;
}
success = document_save_file_as(doc, utf8_filename);
Modified: src/document.c
6 lines changed, 4 insertions(+), 2 deletions(-)
===================================================================
@@ -714,7 +714,8 @@ static gboolean remove_page(guint page_num)
g_free(doc->priv->saved_encoding.encoding);
g_free(doc->file_name);
g_free(doc->real_path);
- tm_workspace_remove_source_file(doc->tm_file, TRUE, !main_status.quitting);
+ tm_workspace_remove_source_file(doc->tm_file, !main_status.quitting);
+ tm_source_file_free(doc->tm_file);
if (doc->priv->tag_tree)
gtk_widget_destroy(doc->priv->tag_tree);
@@ -2617,7 +2618,8 @@ static void document_load_config(GeanyDocument *doc, GeanyFiletype *type,
/* delete tm file object to force creation of a new one */
if (doc->tm_file != NULL)
{
- tm_workspace_remove_source_file(doc->tm_file, TRUE, TRUE);
+ tm_workspace_remove_source_file(doc->tm_file, TRUE);
+ tm_source_file_free(doc->tm_file);
doc->tm_file = NULL;
}
/* load tags files before highlighting (some lexers highlight global typenames) */
Modified: src/plugindata.h
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -603,7 +603,7 @@ typedef struct TagManagerFuncs
gboolean (*tm_workspace_add_source_file) (TMSourceFile *source_file);
void (*tm_workspace_update_source_file) (TMSourceFile *source_file, gboolean update_workspace);
void (*tm_source_file_free) (TMSourceFile *source_file);
- gboolean (*tm_workspace_remove_source_file) (TMSourceFile *source_file, gboolean do_free, gboolean update);
+ gboolean (*tm_workspace_remove_source_file) (TMSourceFile *source_file, gboolean update);
void (*tm_workspace_update) (void);
}
TagManagerFuncs;
Modified: tagmanager/src/tm_workspace.c
26 lines changed, 13 insertions(+), 13 deletions(-)
===================================================================
@@ -92,7 +92,8 @@ const TMWorkspace *tm_get_workspace(void)
return theWorkspace;
}
-/** Adds a source file to the workspace.
+/** Adds a source file to the workspace. At some point, tm_workspace_update_source_file()
+ has to be called to create the source file's tag array.
@param source_file The source file to add to the workspace.
@return TRUE on success, FALSE on failure (e.g. object already exixts).
*/
@@ -113,28 +114,25 @@ static void tm_workspace_remove_file_tags(TMSourceFile *source_file)
tm_tags_remove_file_tags(source_file, theWorkspace->tags_array);
}
-/** Removes a member object from the workspace if it exists.
+/** Removes a source file from the workspace if it exists.
@param source_file Pointer to the source file to be removed.
- @param do_free Whether the source file is to be freed as well.
- @param update Whether to update workspace objects.
+ @param update_workspace Whether to update workspace objects. Has to be TRUE unless
+ tm_workspace_update() is called later.
@return TRUE on success, FALSE on failure (e.g. the source file does not exist).
*/
-gboolean tm_workspace_remove_source_file(TMSourceFile *source_file, gboolean do_free, gboolean update)
+gboolean tm_workspace_remove_source_file(TMSourceFile *source_file, gboolean update_workspace)
{
guint i;
if ((NULL == theWorkspace) || (NULL == theWorkspace->source_files)
|| (NULL == source_file))
return FALSE;
-
for (i=0; i < theWorkspace->source_files->len; ++i)
{
if (theWorkspace->source_files->pdata[i] == source_file)
{
- if (update)
+ if (update_workspace)
tm_workspace_remove_file_tags(source_file);
- if (do_free)
- tm_source_file_free(source_file);
g_ptr_array_remove_index_fast(theWorkspace->source_files, i);
return TRUE;
}
@@ -568,8 +566,8 @@ static void tm_workspace_merge_file_tags(TMSourceFile *source_file)
also lost. The language parameter is automatically set the first time the file
is parsed.
@param source_file The source file to update.
- @param update_workspace If set to TRUE, sends an update signal to the workspace if required. You should
- always set this to TRUE if you are calling this function directly.
+ @param update_workspace Whether to update workspace objects. Has to be TRUE unless
+ tm_workspace_update() is called later.
*/
void tm_workspace_update_source_file(TMSourceFile *source_file, gboolean update_workspace)
{
@@ -647,8 +645,10 @@ void tm_workspace_update_source_file_buffer(TMSourceFile *source_file, guchar* t
#endif
}
-/** Calls tm_source_file_update() for all workspace member source files and creates
- workspace tag array. Use if you want to globally refresh the workspace.
+/** Recreates workspace tag array from all member TMSourceFile objects. Use if you
+ want to globally refresh the workspace. This function does not call tm_source_file_update()
+ which should be called before this function on source files which need to be
+ reparsed.
*/
void tm_workspace_update(void)
{
Modified: tagmanager/src/tm_workspace.h
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -36,7 +36,7 @@ typedef struct
gboolean tm_workspace_add_source_file(TMSourceFile *source_file);
-gboolean tm_workspace_remove_source_file(TMSourceFile *source_file, gboolean do_free, gboolean update);
+gboolean tm_workspace_remove_source_file(TMSourceFile *source_file, gboolean update_workspace);
void tm_workspace_update_source_file(TMSourceFile *source_file, gboolean update_workspace);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list