mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
girepository: Add a gi_repository_new() function
It’s not intended that most people will use this, but it’s going to be quite useful for adding unit tests — we don’t really want the unit tests to share global state (a singleton `GIRepository`) between tests. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: #3155
This commit is contained in:
parent
f5d13c9cf8
commit
0d9b674784
@ -184,7 +184,7 @@ init_globals (void)
|
||||
return;
|
||||
|
||||
if (default_repository == NULL)
|
||||
default_repository = g_object_new (GI_TYPE_REPOSITORY, NULL);
|
||||
default_repository = gi_repository_new ();
|
||||
|
||||
if (typelib_search_path == NULL)
|
||||
{
|
||||
@ -688,6 +688,23 @@ gi_repository_get_default (void)
|
||||
return get_repository (NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gi_repository_new:
|
||||
*
|
||||
* Create a new (non-singleton) #GIRepository.
|
||||
*
|
||||
* Most callers should use gi_repository_get_default() instead, as a singleton
|
||||
* repository is more useful in most situations.
|
||||
*
|
||||
* Returns: (transfer full): a new #GIRepository
|
||||
* Since: 2.80
|
||||
*/
|
||||
GIRepository *
|
||||
gi_repository_new (void)
|
||||
{
|
||||
return g_object_new (GI_TYPE_REPOSITORY, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gi_repository_get_n_infos:
|
||||
* @repository: (allow-none): A #GIRepository or %NULL for the singleton
|
||||
|
@ -103,6 +103,9 @@ GType gi_repository_get_type (void) G_GNUC_CONST;
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GIRepository *gi_repository_get_default (void);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GIRepository *gi_repository_new (void);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
void gi_repository_prepend_search_path (const char *directory);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user