[gnome-music/wip/jfelder/tracker3-rebased: 33/49] coregrilo: Load plugins once coregrilo is built
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/tracker3-rebased: 33/49] coregrilo: Load plugins once coregrilo is built
- Date: Wed, 29 Jul 2020 14:15:25 +0000 (UTC)
commit 45cbcc2cd98ca97ee9a4bda06f65b0a1f63e0e61
Author: Jean Felder <jfelder src gnome org>
Date: Sun May 17 21:24:20 2020 +0200
coregrilo: Load plugins once coregrilo is built
Some sources need access to the registry in order to retrieve custom
keys (for example, the chromaprint source introduced in a later
commit). Such sources wrappers retrieve the CoreGrilo object (and thus
the Grilo registry) by accessing the coregrilo property of the
Application.
However, because of the asynchronous nature of the
`grl_registry_load_all_plugins` function, a wrapper may be created
before the CoreGrilo is initialized. In that case, it will be
impossible to access the Grilo registry.
This issue is fixed by loading all the plugins once the CorGrilo is
initialized. This function can only be called once to prevent any
misuse.
gnomemusic/application.py | 1 +
gnomemusic/coregrilo.py | 11 +++++++++++
2 files changed, 12 insertions(+)
---
diff --git a/gnomemusic/application.py b/gnomemusic/application.py
index e917672a..d6919551 100644
--- a/gnomemusic/application.py
+++ b/gnomemusic/application.py
@@ -71,6 +71,7 @@ class Application(Gtk.Application):
# Order is important: CoreGrilo initializes the Grilo sources,
# which in turn use CoreModel & CoreSelection extensively.
self._coregrilo = CoreGrilo(self)
+ self._coregrilo.load_plugins()
self._settings = Gio.Settings.new('org.gnome.Music')
self._lastfm_scrobbler = LastFmScrobbler(self)
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index 1e896327..b4d0312d 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -96,6 +96,17 @@ class CoreGrilo(GObject.GObject):
self._registry.connect('source-added', self._on_source_added)
self._registry.connect('source-removed', self._on_source_removed)
+ self._plugins_loaded = False
+
+ def load_plugins(self):
+ """Load all the plugins.
+
+ This function can only be called once.
+ """
+ if self._plugins_loaded:
+ self._log.warning("Grilo plugins have already been loaded")
+
+ self._plugins_loaded = True
self._registry.load_all_plugins(True)
weakref.finalize(self, Grl.deinit)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]