hopefully fixing the rest of potential aborts, thx to a suggestion from fif
[booh] / bin / booh
index 4a8b8c83e731cdccb494484c0cbea871d2cbf03a..0da74c021c40b290e7425056d4feba3a1842a263 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -3986,12 +3986,16 @@ def gtk_thread_protect(&proc)
 end
 
 def gtk_thread_flush
-    $protect_gtk_pending_calls.try_lock
-    for closure in $gtk_pending_calls
-        closure.call
+    #- try to lock. we cannot synchronize blindly because this might be called from
+    #- within the timeout flushing procs. if this is the case, not doing anything
+    #- should be ok since the timeout is already flushing them all.
+    if $protect_gtk_pending_calls.try_lock
+        for closure in $gtk_pending_calls
+            closure.call
+        end
+        $gtk_pending_calls = []
+        $protect_gtk_pending_calls.unlock
     end
-    $gtk_pending_calls = []
-    $protect_gtk_pending_calls.unlock
 end
 
 def ask_password_protect
@@ -4228,15 +4232,12 @@ def create_main_window
     $protect_gtk_pending_calls = Mutex.new
     $gtk_pending_calls = []
     Gtk.timeout_add(100) {
-        empty = nil
-        begin
-            $protect_gtk_pending_calls.synchronize {
-                if ! $gtk_pending_calls.empty?
-                    $gtk_pending_calls.shift.call
-                end
-                empty = $gtk_pending_calls.empty?
-            }
-        end while ! empty
+        $protect_gtk_pending_calls.synchronize {
+            for closure in $gtk_pending_calls
+                closure.call
+            end
+            $gtk_pending_calls = []
+        }
         true
     }