GtkQuery: Make API follow GTK+ conversions

We generally have const getters for strings, and the two users
of this API were promptly leaking the (unexpected) copy they
got from gtk_query_get_location and gtk_query_get_text.
This commit is contained in:
Matthias Clasen 2015-07-21 20:39:29 -04:00
parent 9418712782
commit 38a5db8f83
4 changed files with 17 additions and 19 deletions

View File

@ -7272,14 +7272,13 @@ search_setup_widgets (GtkFileChooserWidget *impl)
/* if there already is a query, restart it */
if (priv->search_query)
{
gchar *query;
const gchar *query;
query = gtk_query_get_text (priv->search_query);
if (query)
{
gtk_entry_set_text (GTK_ENTRY (priv->search_entry), query);
search_start_query (impl, query);
g_free (query);
}
else
{

View File

@ -70,10 +70,10 @@ gtk_query_new (void)
}
gchar *
const gchar *
gtk_query_get_text (GtkQuery *query)
{
return g_strdup (query->priv->text);
return query->priv->text;
}
void
@ -87,10 +87,10 @@ gtk_query_set_text (GtkQuery *query,
query->priv->words = NULL;
}
gchar *
const gchar *
gtk_query_get_location (GtkQuery *query)
{
return g_strdup (query->priv->location_uri);
return query->priv->location_uri;
}
void

View File

@ -51,13 +51,13 @@ struct _GtkQueryClass
GType gtk_query_get_type (void);
GtkQuery* gtk_query_new (void);
GtkQuery *gtk_query_new (void);
gchar* gtk_query_get_text (GtkQuery *query);
const gchar *gtk_query_get_text (GtkQuery *query);
void gtk_query_set_text (GtkQuery *query,
const gchar *text);
gchar* gtk_query_get_location (GtkQuery *query);
const gchar *gtk_query_get_location (GtkQuery *query);
void gtk_query_set_location (GtkQuery *query,
const gchar *uri);

View File

@ -320,8 +320,8 @@ static void
gtk_search_engine_tracker_start (GtkSearchEngine *engine)
{
GtkSearchEngineTracker *tracker;
gchar *search_text;
gchar *location_uri;
const gchar *search_text;
const gchar *location_uri;
GString *sparql;
gboolean recursive;
@ -386,7 +386,6 @@ gtk_search_engine_tracker_start (GtkSearchEngine *engine)
get_query_results (tracker, sparql->str, query_callback, g_object_ref (tracker));
g_string_free (sparql, TRUE);
g_free (search_text);
}
static void