diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2021-11-28 11:54:17 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2022-01-10 11:56:30 +0100 |
commit | 787c4ff6e2132559545475b9dae31eebbe49ff7a (patch) | |
tree | 76bfb44fb68a1bd2c0118e9d258269d4f8152520 /src/libtracker-sparql/tracker-serializer.c | |
parent | 5a50f5f8246c1829b4692b12893a798a4959754f (diff) | |
download | tracker-787c4ff6e2132559545475b9dae31eebbe49ff7a.tar.gz |
libtracker-sparql: Ensure to register a single instance of serializers
For now, the private TrackerSerializer API was only used in the
TrackerEndpointHttp object, which is compiled as a loadable module since
we support linking with soup 2.x and 3.x simultaneously.
Now that we are introducing usage of this private API from other places
in code, we risk getting the dreaded "type already registered" errors
from GType, since each of libtracker-sparql and the soup modules will
try to register their own.
Make creation of serializers more lenient wrt the GType lookup, so
there's no double registration of the same type, and ensure these GTypes
are initialized from libtracker-sparql so there's no confusion about
who comes first.
This is yet another braindead hack about libsoup loadable modules that
can be removed when we can pick one of them at build time.
Diffstat (limited to 'src/libtracker-sparql/tracker-serializer.c')
-rw-r--r-- | src/libtracker-sparql/tracker-serializer.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libtracker-sparql/tracker-serializer.c b/src/libtracker-sparql/tracker-serializer.c index 4109bfafe..317b621a9 100644 --- a/src/libtracker-sparql/tracker-serializer.c +++ b/src/libtracker-sparql/tracker-serializer.c @@ -133,10 +133,14 @@ tracker_serializer_new (TrackerSparqlCursor *cursor, switch (format) { case TRACKER_SERIALIZER_FORMAT_JSON: - type = TRACKER_TYPE_SERIALIZER_JSON; + type = g_type_from_name ("TrackerSerializerJson"); + if (type == 0) + type = TRACKER_TYPE_SERIALIZER_JSON; break; case TRACKER_SERIALIZER_FORMAT_XML: - type = TRACKER_TYPE_SERIALIZER_XML; + type = g_type_from_name ("TrackerSerializerXml"); + if (type == 0) + type = TRACKER_TYPE_SERIALIZER_XML; break; default: g_warn_if_reached (); |