[gnome-games] Don't start collection loading twice
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] Don't start collection loading twice
- Date: Thu, 14 Nov 2019 22:45:02 +0000 (UTC)
commit c9fb107f59e180e0f23c91560a4d75af3db5c0ad
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Nov 15 03:43:11 2019 +0500
Don't start collection loading twice
Oops
src/core/game-collection.vala | 12 +++++++++---
src/ui/application.vala | 3 +++
2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/core/game-collection.vala b/src/core/game-collection.vala
index d7732849..b09b433a 100644
--- a/src/core/game-collection.vala
+++ b/src/core/game-collection.vala
@@ -13,6 +13,7 @@ private class Games.GameCollection : Object {
private HashTable<Platform, Array<RunnerFactory>> runner_factories_for_platforms;
public bool paused { get; set; }
+ private SourceFunc search_games_cb;
construct {
games = new GenericSet<Game> (Game.hash, Game.equal);
@@ -77,26 +78,31 @@ private class Games.GameCollection : Object {
}
public async void search_games () {
- SourceFunc callback = search_games.callback;
+ if (search_games_cb != null)
+ return;
+
+ search_games_cb = search_games.callback;
ThreadFunc<void*> run = () => {
foreach (var source in sources)
foreach (var uri in source) {
if (paused) {
- Idle.add ((owned) callback);
+ Idle.add ((owned) search_games_cb);
return null;
}
add_uri (uri);
}
- Idle.add ((owned) callback);
+ Idle.add ((owned) search_games_cb);
return null;
};
new Thread<void*> (null, (owned) run);
yield;
+
+ search_games_cb = null;
}
public Runner? create_runner (Game game) {
diff --git a/src/ui/application.vala b/src/ui/application.vala
index a9a1e726..e9106291 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -349,6 +349,9 @@ public class Games.Application : Gtk.Application {
}
public void set_pause_loading (bool paused) {
+ if (game_collection.paused == paused)
+ return;
+
game_collection.paused = paused;
if (!paused)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]