[Xfce4-commits] <eatmonkey:aria2-xml-rpc> Avoid readding gid in treestore after removing a download

Mike Massonnet noreply at xfce.org
Sat Feb 13 12:38:02 CET 2010


Updating branch refs/heads/aria2-xml-rpc
         to 3abcd26a8115d5e473c9d3ac0202cad4167f8f66 (commit)
       from 63958684896dac38fc0154265039dca17cf7405a (commit)

commit 3abcd26a8115d5e473c9d3ac0202cad4167f8f66
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Sat Feb 13 12:33:22 2010 +0100

    Avoid readding gid in treestore after removing a download
    
    When a download was removed it could reappear in the treestore (it's
    visible for torrents that need to cut down connections). Now the gids
    removed download are stored in an array and compared in the update_row
    callback.

 src/eatmanager.rb |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/eatmanager.rb b/src/eatmanager.rb
index 077263b..28bd20e 100644
--- a/src/eatmanager.rb
+++ b/src/eatmanager.rb
@@ -19,9 +19,13 @@ end
 class Eat::Manager
 
 	def initialize()
+		# Store manually removed downloads to avoid readding them into the tree store
+		@removed_downloads = Array.new
+
 		# Setup aria2 listener
 		@aria2 = Eat::Aria2Listener.instance
 		@aria2.signal_connect("connected") {
+			@removed_downloads.clear
 			update_newdl_dialog
 			set_sensitive(true)
 			@infobar.hide_all
@@ -165,6 +169,10 @@ class Eat::Manager
 		row_iter = nil
 		gid_i = gid.to_i
 
+		# Find gid in removed downloads
+		return if @removed_downloads.include? gid_i
+
+		# Retrieve status information on gid
 		status = @aria2.tell_status(gid)
 		return if status.empty?
 
@@ -421,11 +429,10 @@ class Eat::Manager
 
 	def action_remove()
 		@treeview.selection.selected_each do |model, path, iter|
-			# TODO aria2 may respond to the remove request after the callback
-			# and thus re-add a new iter
 			gid = iter[0]
 			@aria2.remove(gid.to_s)
 			@liststore.remove(iter)
+			@removed_downloads << gid
 		end
 	end
 



More information about the Xfce4-commits mailing list