summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Toso <victortoso@gnome.org>2022-08-21 11:43:03 +0200
committerVictor Toso <victortoso@gnome.org>2022-08-21 11:43:05 +0200
commit9ba39b357b454912b7f7502c64dd76af4978c5ac (patch)
treea8e0762b9c97547458608f063f60456be42af7bb
parent98cbc65e258209c92a260a7641e4b9df2c9e58fa (diff)
downloadgrilo-plugins-9ba39b357b454912b7f7502c64dd76af4978c5ac.tar.gz
tmdb: without config, run a single request
When we need to request the config, the request's callback will flush out the queue of requests. So, when we need the config, be sure to only run_pending_requests with max_num_request set to 1. Also, to avoid reuse of the same GrlTmdbRequest, I've added a warning to its grl_tmdb_request_run_async(). Found this after switching internals of GrlNetWc to use GTask instead of GSimpleAsyncResult.
-rw-r--r--src/tmdb/grl-tmdb-request.c6
-rw-r--r--src/tmdb/grl-tmdb.c5
2 files changed, 10 insertions, 1 deletions
diff --git a/src/tmdb/grl-tmdb-request.c b/src/tmdb/grl-tmdb-request.c
index c17ba8b..2c6a18e 100644
--- a/src/tmdb/grl-tmdb-request.c
+++ b/src/tmdb/grl-tmdb-request.c
@@ -575,6 +575,12 @@ grl_tmdb_request_run_async (GrlTmdbRequest *self,
call = new_call;
}
+ if (self->priv->task != NULL) {
+ GRL_WARNING("Request %p to %s is already in progress", self, call);
+ g_free (call);
+ return;
+ }
+
self->priv->task = g_task_new (G_OBJECT (self),
cancellable,
callback,
diff --git a/src/tmdb/grl-tmdb.c b/src/tmdb/grl-tmdb.c
index 99f3391..727d253 100644
--- a/src/tmdb/grl-tmdb.c
+++ b/src/tmdb/grl-tmdb.c
@@ -1377,7 +1377,6 @@ grl_tmdb_source_resolve (GrlSource *source,
GRL_DEBUG ("Running initial search for title \"%s\"...", title);
request = grl_tmdb_request_new_search (closure->self->priv->api_key, title);
queue_request (closure, request, on_search_ready);
- run_pending_requests (closure, 1);
} else {
GRL_DEBUG ("Running %s lookup for movie #%" G_GUINT64_FORMAT "...",
closure->slow ? "slow" : "fast", movie_id);
@@ -1387,7 +1386,11 @@ grl_tmdb_source_resolve (GrlSource *source,
} else {
queue_detail_request (closure, GRL_TMDB_REQUEST_DETAIL_MOVIE);
}
+ }
+ if (self->priv->config_pending || title == NULL) {
+ run_pending_requests (closure, 1);
+ } else {
run_pending_requests (closure, G_MAXINT);
}
}