From: gc Date: Sat, 23 Feb 2008 22:34:44 +0000 (+0000) Subject: take care of opening another directory while processing X-Git-Tag: 0.9.0~120 X-Git-Url: http://git.zarb.org/?p=booh;a=commitdiff_plain;h=841ee5ff1e31cc8a51ae9774d2231b8e182b8ff8 take care of opening another directory while processing --- diff --git a/bin/booh-classifier b/bin/booh-classifier index 41e3de0..9a9e7ef 100644 --- a/bin/booh-classifier +++ b/bin/booh-classifier @@ -493,10 +493,22 @@ def run_preloader_real if i < $allentries.size $allentries[i].pixbuf_main end + #- in case just loaded another directory + if $preloader_force_exit + $preloader_running = false + $preloader_force_exit = false + return + end i = index - j if i >= 0 $allentries[i].pixbuf_main end + #- in case just loaded another directory + if $preloader_force_exit + $preloader_running = false + $preloader_force_exit = false + return + end end check_memory_free_cache_if_needed end @@ -965,7 +977,7 @@ def show_entry(entry, i) Gtk.main_iteration while Gtk.events_pending? end -def show_entries +def show_entries(allentries) sb_msg(_("Loading images...")) $loading_progressbar.fraction = 0 $loading_progressbar.text = utf8(_("Loading... %d%") % 0) @@ -974,17 +986,27 @@ def show_entries total_loaded_files = 0 total_loaded_size = 0 i = 0 - while i < $allentries.size + while i < allentries.size # printf "%d %s\n", i, __LINE__ - entry = $allentries[i] + entry = allentries[i] if i == 0 loaded_pixbuf = entry.pixbuf_main else loaded_pixbuf = entry.pixbuf_thumbnail end + if $allentries != allentries + #- loaded another directory while this one was not yet finished + msg 3, "allentries differ, stopping this deprecated load" + return + end if loaded_pixbuf show_entry(entry, i) + if $allentries != allentries + #- loaded another directory while this one was not yet finished + msg 3, "allentries differ, stopping this deprecated load" + return + end total_loaded_size += file_size(entry.path) if i % 4 == 0 @@ -994,7 +1016,7 @@ def show_entries i += 1 if i > $config['preload-distance'].to_i && i <= $config['preload-distance'].to_i * 2 #- when we're at preload distance, beging preloading to preload distance - $allentries[i - $config['preload-distance'].to_i].pixbuf_main + allentries[i - $config['preload-distance'].to_i].pixbuf_main end if i == $config['preload-distance'].to_i * 2 + 1 #- when we're after double preload distance, activate normal preloading @@ -1002,9 +1024,9 @@ def show_entries end else - $allentries.delete_at(i) + allentries.delete_at(i) end - $loading_progressbar.fraction = i.to_f / $allentries.size + $loading_progressbar.fraction = i.to_f / allentries.size $loading_progressbar.text = utf8(_("Loading... %d%") % (100 * $loading_progressbar.fraction)) end if i <= $config['preload-distance'].to_i * 2 @@ -1103,7 +1125,7 @@ def open_dir_popup end fc.destroy if load - show_entries + show_entries($allentries) end end @@ -1542,6 +1564,9 @@ end def reset_thumbnails $allentries = [] + if $preloader_running + $preloader_force_exit = true + end for child in $imagesline.children $imagesline.remove(child) end @@ -1614,7 +1639,7 @@ if ARGV[0] if msg = open_dir(ARGV[0]) puts msg else - show_entries + show_entries($allentries) end end Gtk.main