[gnome-code-assistance] [backends/jscommon] Fix racy exit from dispose



commit 4b55b0217027e3aa6dd365327d6e5ec066a3ddf4
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sat Nov 16 13:56:40 2013 +0100

    [backends/jscommon] Fix racy exit from dispose

 .../gnome/codeassistance/transport_dbus.js         |   27 ++++++++++++++++---
 1 files changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/backends/jscommon/gnome/codeassistance/transport_dbus.js 
b/backends/jscommon/gnome/codeassistance/transport_dbus.js
index b962bf4..870f045 100644
--- a/backends/jscommon/gnome/codeassistance/transport_dbus.js
+++ b/backends/jscommon/gnome/codeassistance/transport_dbus.js
@@ -138,6 +138,8 @@ Service.prototype = {
     },
 
     DisposeAsync: function(args, invocation) {
+        var retval;
+
         this.server.dbusAsync(args, invocation, function(sender, path) {
             if (sender in this.apps) {
                 let app = this.apps[sender];
@@ -148,10 +150,17 @@ Service.prototype = {
                     delete app.docs[cpath];
 
                     if (Object.keys(app.docs).length == 0) {
-                        this.disposeApp(app);
+                        retval = this.disposeApp(app);
                     }
                 }
             }
+        }, function() {
+            if (retval)
+            {
+                GLib.idle_add(GLib.PRIORITY_LOW, Lang.bind(this, function() {
+                    this.main.quit();
+                }));
+            }
         });
     }
 };
@@ -357,9 +366,7 @@ Server.prototype = {
         app.docs = {};
         delete this.apps[app.name];
 
-        if (Object.keys(this.apps).length == 0) {
-            this.main.quit();
-        }
+        return (Object.keys(this.apps).length == 0);
     },
 
     makeOutSignature: function(args) {
@@ -373,7 +380,7 @@ Server.prototype = {
     },
 
     // Mostly copied from gjs
-    dbusAsync: function(args, invocation, f) {
+    dbusAsync: function(args, invocation, f, finishedcb) {
         var retval;
 
         try {
@@ -395,6 +402,11 @@ Server.prototype = {
                 invocation.return_dbus_error(name, errLoc + ': ' + e.message);
             }
 
+            if (finishedcb)
+            {
+                finishedcb.call(this);
+            }
+
             return;
         }
 
@@ -429,6 +441,11 @@ Server.prototype = {
         }
 
         invocation.return_value(retval);
+
+        if (finishedcb)
+        {
+            finishedcb.call(this);
+        }
     }
 };
 


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