[libgnome-games-support] Use a custom main context in add_score_sync



commit f59e41deb420c4d8cdc26d1fe5ea367e0cdeac82
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Thu Oct 20 21:48:00 2016 -0500

    Use a custom main context in add_score_sync
    
    Otherwise, application sources could unexpectedly be dispatched while
    the application is importing scores.
    
    
https://developer.gnome.org/programming-guidelines/stable/main-contexts.html.en#using-gmaincontext-in-a-library

 games/scores/context.vala |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/games/scores/context.vala b/games/scores/context.vala
index d58281d..64c3e98 100644
--- a/games/scores/context.vala
+++ b/games/scores/context.vala
@@ -242,10 +242,12 @@ public class Context : Object
 
     internal bool add_score_sync (Score score, Category category) throws Error
     {
-        var main_loop = new MainLoop ();
+        var main_context = new MainContext ();
+        var main_loop = new MainLoop (main_context);
         var ret = false;
         Error error = null;
 
+        main_context.push_thread_default ();
         add_score_internal.begin (score, category, false, null, (object, result) => {
             try
             {
@@ -258,6 +260,7 @@ public class Context : Object
             main_loop.quit ();
         });
         main_loop.run ();
+        main_context.pop_thread_default ();
 
         if (error != null)
             throw error;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]