@@ -53,6 +53,8 @@ module Collision
5353 @hash_results = Hash (Symbol , String ).new
5454 @file_path_queued : Path ? = nil
5555
56+ property working : Bool = false
57+
5658 def continue_queue
5759 return if @file_path_queued .nil?
5860 self .file = @file_path_queued .not_nil!
@@ -69,26 +71,45 @@ module Collision
6971 @file_path_queued = nil
7072 Collision .atomic_increase
7173 @fileInfo .title = filepath.basename.to_s
72- Collision ::LOGGER .debug { " Begin generating hashes" }
73- Collision ::Checksum .new.generate(filepath.to_s, @progressbar ) do |res |
74- GLib .idle_add do
75- res.each do |hash_type , hash_value |
76- @hash_results [hash_type] = hash_value
77- @hash_rows [hash_type].subtitle = hash_value.size < 8 ? hash_value : Collision .split_by_4(hash_value)
78- end
7974
80- @mainStack .visible_child_name = " results "
81- @headerbarViewSwitcher .visible = true
82- @openFileBtn .visible = true
83- @switcher_bar .visible = true
84- Collision .atomic_decrease
85- self .application.not_nil!.windows.each do | window |
86- Window .cast(window).continue_queue
75+ begin
76+ self .working = true
77+ Collision :: LOGGER .debug { " Begin generating hashes " }
78+ Collision :: Checksum .new.generate(filepath.to_s, @progressbar ) do | res |
79+ if ! self .visible
80+ flow_queue
81+ next
8782 end
8883
89- false
84+ GLib .idle_add do
85+ res.each do |hash_type , hash_value |
86+ @hash_results [hash_type] = hash_value
87+ @hash_rows [hash_type].subtitle = hash_value.size < 8 ? hash_value : Collision .split_by_4(hash_value)
88+ end
89+
90+ @mainStack .visible_child_name = " results"
91+ @headerbarViewSwitcher .visible = true
92+ @openFileBtn .visible = true
93+ @switcher_bar .visible = true
94+ flow_queue
95+ false
96+ end
9097 end
98+ rescue ex
99+ flow_queue
100+ raise ex
101+ end
102+ end
103+
104+ # Force inline queue recovery
105+ macro flow_queue
106+ self .working = false
107+ Collision .atomic_decrease
108+ self .application.not_nil!.windows.each do |window |
109+ Window .cast(window).continue_queue
91110 end
111+
112+ self .destroy unless self .visible
92113 end
93114
94115 # For Gio::File.
@@ -302,7 +323,7 @@ module Collision
302323 end
303324
304325 @mainDnd .enter_signal.connect do
305- @dropOverlayRevealer .reveal_child = true
326+ @dropOverlayRevealer .reveal_child = true unless @mainStack .visible_child_name == " spinner "
306327 Gdk ::DragAction ::Copy
307328 end
308329
@@ -311,6 +332,8 @@ module Collision
311332 end
312333
313334 @mainDnd .drop_signal.connect do |value |
335+ next false if @mainStack .visible_child_name == " spinner"
336+
314337 if LibGObject .g_type_check_value_holds(value, Gdk ::FileList .g_type)
315338 files = Gdk ::FileList .new(LibGObject .g_value_get_boxed(value), GICrystal ::Transfer ::None ).files
316339 file = nil
@@ -373,6 +396,12 @@ module Collision
373396 Collision ::LOGGER .debug { ex }
374397 end
375398 end
399+
400+ self .close_request_signal.connect do
401+ self .hide_on_close = true if self .working && self .application.not_nil!.windows.size > 1
402+
403+ false
404+ end
376405 end
377406 end
378407end
0 commit comments