Commit 4a940d94 authored by Michael Catanzaro's avatar Michael Catanzaro

search-engine-manager: get_address() must return NULL

The search-engine-dialog relies on get_address() returning NULL to
detect new search engines. It doesn't function properly otherwise. All
code using this function just needs to be prepared to handle a NULL
address.

In contrast, get_address_for_default_engine() really does need to always
return a result. At least, it's more convenient this way, so that
calling code doesn't have to handle that manually. Rename the function
to make this more clear and reduce confusion, as it would be odd to have
two parallel functions function differently in this respect.

https://bugzilla.gnome.org/show_bug.cgi?id=787458
parent 641af185
......@@ -276,7 +276,7 @@ ephy_embed_utils_autosearch_address (const char *search_key)
shell = ephy_embed_shell_get_default ();
search_engine_manager = ephy_embed_shell_get_search_engine_manager (shell);
address_search = ephy_search_engine_manager_get_address_for_default_engine (search_engine_manager);
address_search = ephy_search_engine_manager_get_default_search_address (search_engine_manager);
query_param = soup_form_encode ("q", search_key, NULL);
#pragma GCC diagnostic push
......
......@@ -147,11 +147,11 @@ ephy_search_engine_manager_get_address (EphySearchEngineManager *manager,
if (info)
return info->address;
return FALLBACK_ADDRESS;
return NULL;
}
const char *
ephy_search_engine_manager_get_address_for_default_engine (EphySearchEngineManager *manager)
ephy_search_engine_manager_get_default_search_address (EphySearchEngineManager *manager)
{
char *name;
const char *address;
......@@ -160,7 +160,7 @@ ephy_search_engine_manager_get_address_for_default_engine (EphySearchEngineManag
address = ephy_search_engine_manager_get_address (manager, name);
g_free (name);
return address;
return address ? address : FALLBACK_ADDRESS;
}
const char *
......
......@@ -39,7 +39,7 @@ G_DECLARE_FINAL_TYPE (EphySearchEngineManager, ephy_search_engine_manager, EPHY,
EphySearchEngineManager *ephy_search_engine_manager_new (void);
const char *ephy_search_engine_manager_get_address (EphySearchEngineManager *manager,
const char *name);
const char *ephy_search_engine_manager_get_address_for_default_engine
const char *ephy_search_engine_manager_get_default_search_address
(EphySearchEngineManager *manager);
const char *ephy_search_engine_manager_get_bang (EphySearchEngineManager *manager,
const char *name);
......
......@@ -286,7 +286,7 @@ launch_search (EphySearchProvider *self,
shell = ephy_embed_shell_get_default ();
search_engine_manager = ephy_embed_shell_get_search_engine_manager (shell);
address_search = ephy_search_engine_manager_get_address_for_default_engine (search_engine_manager);
address_search = ephy_search_engine_manager_get_default_search_address (search_engine_manager);
search_string = g_strjoinv (" ", terms);
query_param = soup_form_encode ("q", search_string, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment