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
$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
}