Author: andar

Revision: 5984

Log:
        Fix crash in Windows when creating a torrent

Diff:
Modified: branches/1.2_RC/ChangeLog
===================================================================
--- branches/1.2_RC/ChangeLog   2009-11-29 07:37:29 UTC (rev 5983)
+++ branches/1.2_RC/ChangeLog   2009-11-29 07:38:29 UTC (rev 5984)
@@ -5,6 +5,7 @@
 ==== GtkUI ====
        * Attempt to register as the default magnet uri handler in GNOME on 
startup
        * Properly show 100.00% and reduce number of progress bar updates 
during a torrent creation
+       * Fix crash in Windows when creating a torrent
        
 === Deluge 1.2.0_rc4 (24 November 2009) ===
 ==== Core ====

Modified: branches/1.2_RC/deluge/ui/gtkui/createtorrentdialog.py
===================================================================
--- branches/1.2_RC/deluge/ui/gtkui/createtorrentdialog.py      2009-11-29 
07:37:29 UTC (rev 5983)
+++ branches/1.2_RC/deluge/ui/gtkui/createtorrentdialog.py      2009-11-29 
07:38:29 UTC (rev 5984)
@@ -40,6 +40,8 @@
 import gobject
 import base64
 
+from twisted.internet.threads import deferToThread
+
 from deluge.ui.client import client
 import listview
 import deluge.component as component
@@ -318,9 +320,10 @@
             
self.glade.get_widget("progress_dialog").set_transient_for(component.get("MainWindow").window)
             self.glade.get_widget("progress_dialog").show_all()
 
-            import threading
-            threading.Thread(target=self.create_torrent,
-                args=(
+            def hide_progress(result):
+                self.glade.get_widget("progress_dialog").hide_all()
+                
+            deferToThread(self.create_torrent,
                     path,
                     tracker,
                     piece_length,
@@ -331,7 +334,7 @@
                     private,
                     author,
                     trackers,
-                    add_to_session)).start()
+                    add_to_session).addCallback(hide_progress)
 
         chooser.destroy()
         self.dialog.destroy()
@@ -350,7 +353,7 @@
             private=private,
             created_by=created_by,
             trackers=trackers)
-        self.glade.get_widget("progress_dialog").hide_all()
+
         if add_to_session:
             client.core.add_torrent_file(
                 os.path.split(target)[-1],

Modified: trunk/deluge/ui/gtkui/createtorrentdialog.py
===================================================================
--- trunk/deluge/ui/gtkui/createtorrentdialog.py        2009-11-29 07:37:29 UTC 
(rev 5983)
+++ trunk/deluge/ui/gtkui/createtorrentdialog.py        2009-11-29 07:38:29 UTC 
(rev 5984)
@@ -40,6 +40,8 @@
 import gobject
 import base64
 
+from twisted.internet.threads import deferToThread
+
 from deluge.ui.client import client
 import listview
 import deluge.component as component
@@ -318,9 +320,10 @@
             
self.glade.get_widget("progress_dialog").set_transient_for(component.get("MainWindow").window)
             self.glade.get_widget("progress_dialog").show_all()
 
-            import threading
-            threading.Thread(target=self.create_torrent,
-                args=(
+            def hide_progress(result):
+                self.glade.get_widget("progress_dialog").hide_all()
+                
+            deferToThread(self.create_torrent,
                     path,
                     tracker,
                     piece_length,
@@ -331,7 +334,7 @@
                     private,
                     author,
                     trackers,
-                    add_to_session)).start()
+                    add_to_session).addCallback(hide_progress)
 
         chooser.destroy()
         self.dialog.destroy()
@@ -350,7 +353,7 @@
             private=private,
             created_by=created_by,
             trackers=trackers)
-        self.glade.get_widget("progress_dialog").hide_all()
+
         if add_to_session:
             client.core.add_torrent_file(
                 os.path.split(target)[-1],


--

You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.


Reply via email to