girepository: Make gi_repository_find_by_gtype() deterministic

When faced with a `GType` which is present in multiple typelibs, the old
implementation was not deterministic, as it iterated over a hash table
of typelibs. The iteration order of a hash table is not deterministic.

Use the new `ordered_typelibs` and `ordered_lazy_typelibs` arrays to
iterate instead, making the order deterministic.

Add a unit test to check this. In particular, to check that symbols
which are present in both `Gio` and `GioUnix` are correctly resolved as
being from `GioUnix`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3303
This commit is contained in:
Philip Withnall
2024-05-02 16:03:24 +01:00
parent 14d196a6c1
commit 81b16a88d1
5 changed files with 103 additions and 25 deletions

View File

@@ -29,6 +29,11 @@ if enable_gir
gio_gir,
]
gio_platform_gir_testing_dep = [
gio_gir_testing_dep,
gio_platform_gir,
]
girepository_gir_testing_dep = [
gio_gir_testing_dep,
girepository_gir,
@@ -46,7 +51,8 @@ if enable_gir
'depends': gobject_gir_testing_dep,
},
'repository' : {
'depends': gio_gir_testing_dep,
'depends': [gio_gir_testing_dep, gio_platform_gir_testing_dep],
'dependencies': [libgio_dep],
},
'repository-search-paths' : {
'c_args': '-DGOBJECT_INTROSPECTION_LIBDIR="@0@"'.format(glib_libdir),