Module: Lich::Common::GtkTimeoutRetention
- Included in:
- Lich::Common
- Defined in:
- documented/common/gtk.rb
Overview
Keep timeout callbacks alive until they fire or stop repeating.
Instance Method Summary collapse
Instance Method Details
#add(*args, &block) ⇒ Object
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'documented/common/gtk.rb', line 309 def add(*args, &block) return super(*args, &block) unless block callback_id = nil retained = proc do |*callback_args| begin ret = block.call(*callback_args) Lich::Common.with_gtk_registry_lock { Lich::Common.gtk_timeout_callbacks.delete(callback_id) } unless ret ret rescue StandardError Lich::Common.with_gtk_registry_lock { Lich::Common.gtk_timeout_callbacks.delete(callback_id) } raise end end callback_id = super(*args, &retained) Lich::Common.with_gtk_registry_lock { Lich::Common.gtk_timeout_callbacks[callback_id] = retained } if callback_id callback_id end |