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 25b7ecf895
commit 48988a4098
5 changed files with 103 additions and 25 deletions

View File

@@ -261,6 +261,7 @@ if host_system == 'windows'
'--identifier-prefix=GWin32'
],
)
gio_platform_gir = gio_win32_gir
else
gio_unix_gir_c_includes = []
foreach h: gio_unix_include_headers
@@ -289,6 +290,7 @@ else
'--identifier-prefix=GUnix'
],
)
gio_platform_gir = gio_unix_gir
endif
# GIRepository