From f80e978f0040ad16d3fa7ac7a5a4c9f28cbc495c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 13 Feb 2024 16:58:25 +0000 Subject: [PATCH] girwriter: Take the GIRepository as a parameter We certainly won't find the requested namespace in a newly-created repository with no typelibs loaded. Fixes: 9ab84bc1 "girwriter: Stop using the singleton GIRepository" Signed-off-by: Simon McVittie --- girepository/decompiler/decompiler.c | 2 +- girepository/girwriter-private.h | 4 +++- girepository/girwriter.c | 9 +++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/girepository/decompiler/decompiler.c b/girepository/decompiler/decompiler.c index aad3cf58b..821b8ae58 100644 --- a/girepository/decompiler/decompiler.c +++ b/girepository/decompiler/decompiler.c @@ -118,7 +118,7 @@ main (int argc, char *argv[]) if (namespace == NULL) g_error ("failed to load typelib: %s", error->message); - gi_ir_writer_write (output, namespace, needs_prefix, show_all); + gi_ir_writer_write (repository, output, namespace, needs_prefix, show_all); /* when writing to stdout, stop after the first module */ if (input[i + 1] && !output) diff --git a/girepository/girwriter-private.h b/girepository/girwriter-private.h index 3d060ef3b..6c67e00cd 100644 --- a/girepository/girwriter-private.h +++ b/girepository/girwriter-private.h @@ -24,10 +24,12 @@ #pragma once #include +#include G_BEGIN_DECLS -void gi_ir_writer_write (const char *filename, +void gi_ir_writer_write (GIRepository *repository, + const char *filename, const char *ns, gboolean needs_prefix, gboolean show_all); diff --git a/girepository/girwriter.c b/girepository/girwriter.c index 4b771bd0b..a0307a29d 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -1319,6 +1319,7 @@ write_union_info (const char *ns, /** * gi_ir_writer_write: + * @repository: repository containing @ns * @filename: (type filename): filename to write to * @ns: GIR namespace to write * @needs_prefix: if the filename needs prefixing @@ -1330,7 +1331,8 @@ write_union_info (const char *ns, * Since: 2.80 */ void -gi_ir_writer_write (const char *filename, +gi_ir_writer_write (GIRepository *repository, + const char *filename, const char *ns, gboolean needs_prefix, gboolean show_all) @@ -1338,11 +1340,8 @@ gi_ir_writer_write (const char *filename, FILE *ofile; size_t i, j; char **dependencies; - GIRepository *repository = NULL; Xml *xml; - repository = gi_repository_new (); - if (filename == NULL) ofile = stdout; else @@ -1446,6 +1445,4 @@ gi_ir_writer_write (const char *filename, xml_end_element (xml, "repository"); xml_free (xml); - - g_clear_object (&repository); }