summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrafspiny <rafspiny@gmail.com>2021-10-15 08:21:50 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-10-15 08:21:50 +0100
commitef8ebed4f5d7b320e0b7dd3ad6446650caa1ba5e (patch)
tree33aaa1aaaee1a77b8a0fbd7d823c9c676a3962d0
parentc7264e9ed5eb1725d926cbc76324bfbb9bfc6da9 (diff)
The app was not able to add a torrent.HEADmaster
Summary: Plus, the app was crashing when the Dialog to add a torrent was being closed. This is due to some not very clear memory issue in freeing the Dialog box. Unable to identify the root cause, I moved the .delete() of the Dialog at the shutdown of the application. Fixes #T8885 Reviewers: raster Differential Revision: https://phab.enlightenment.org/D12297
-rw-r--r--epour/gui/TorrentSelector.py37
-rw-r--r--epour/gui/__init__.py11
2 files changed, 35 insertions, 13 deletions
diff --git a/epour/gui/TorrentSelector.py b/epour/gui/TorrentSelector.py
index c6c8993..88ab09e 100644
--- a/epour/gui/TorrentSelector.py
+++ b/epour/gui/TorrentSelector.py
@@ -40,6 +40,7 @@ from efl.elementary import Spinner
40# ELM_SEL_FORMAT_TEXT 40# ELM_SEL_FORMAT_TEXT
41 41
42from .Widgets import UnitSpinner 42from .Widgets import UnitSpinner
43from ..session import lt_version_post_breaking_change
43 44
44EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND 45EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
45EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0 46EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
@@ -139,9 +140,13 @@ seed, this flag has no effect.'''
139 def __init__(self, parent, session, t_uri=None): 140 def __init__(self, parent, session, t_uri=None):
140 DialogWindow.__init__( 141 DialogWindow.__init__(
141 self, parent, "addtorrent", _("Add Torrent"), 142 self, parent, "addtorrent", _("Add Torrent"),
142 size=(scale * 400, scale * 400), autodel=True 143 size=(scale * 400, scale * 400), autodel=False
143 ) 144 )
144 145
146 def _cb_close(self):
147 self.hide()
148
149 self.callback_delete_request_add(lambda o: _cb_close(o))
145 self.add_dict = {} 150 self.add_dict = {}
146 151
147 scrol = Scroller( 152 scrol = Scroller(
@@ -160,20 +165,20 @@ seed, this flag has no effect.'''
160 box.pack_end(hbox) 165 box.pack_end(hbox)
161 hbox.show() 166 hbox.show()
162 167
163 uri_entry = Entry( 168 self.uri_entry = Entry(
164 box, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, 169 box, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ,
165 single_line=True, scrollable=True 170 single_line=True, scrollable=True
166 ) 171 )
167 uri_entry.part_text_set("guide", _("Enter torrent file path / magnet URI / info hash")) 172 self.uri_entry.part_text_set("guide", _("Enter torrent file path / magnet URI / info hash"))
168 173
169 if t_uri: 174 if t_uri:
170 uri_entry.entry = utf8_to_markup(t_uri) 175 self.uri_entry.entry = utf8_to_markup(t_uri)
171 176
172 hbox.pack_end(uri_entry) 177 hbox.pack_end(self.uri_entry)
173 uri_entry.show() 178 self.uri_entry.show()
174 179
175 fsb = Button(box, text=_("Select file")) 180 fsb = Button(box, text=_("Select file"))
176 fsb.callback_clicked_add(lambda x: TorrentFs(self, uri_entry)) 181 fsb.callback_clicked_add(lambda x: TorrentFs(self, self.uri_entry))
177 hbox.pack_end(fsb) 182 hbox.pack_end(fsb)
178 fsb.show() 183 fsb.show()
179 184
@@ -239,7 +244,12 @@ seed, this flag has no effect.'''
239 flags = flags ^ int(add_torrent_params_flags_t.flag_auto_managed) 244 flags = flags ^ int(add_torrent_params_flags_t.flag_auto_managed)
240 self.add_dict["flags"] = flags 245 self.add_dict["flags"] = flags
241 246
242 for name, flag in sorted(add_torrent_params_flags_t.names.items()): 247 if lt_version_post_breaking_change:
248 items = sorted(add_torrent_params_flags_t.__dict__.items())
249 flags_list = [flag for flag in items if not flag[0].startswith("_")]
250 else:
251 flags_list = sorted(add_torrent_params_flags_t.names.items())
252 for name, flag in flags_list:
243 if not int(flag) in self.names.keys(): 253 if not int(flag) in self.names.keys():
244 continue 254 continue
245 c = Check( 255 c = Check(
@@ -312,6 +322,9 @@ seed, this flag has no effect.'''
312 box.show() 322 box.show()
313 scrol.show() 323 scrol.show()
314 324
325 def del_dialog_cb(btn):
326 self.hide()
327
315 def add_torrent_cb(btn, uri_entry, session, add_dict): 328 def add_torrent_cb(btn, uri_entry, session, add_dict):
316 uri = uri_entry.entry 329 uri = uri_entry.entry
317 330
@@ -323,11 +336,13 @@ seed, this flag has no effect.'''
323 session.fill_add_dict_based_on_uri(add_dict, uri) 336 session.fill_add_dict_based_on_uri(add_dict, uri)
324 session.add_torrent_with_dict(add_dict) 337 session.add_torrent_with_dict(add_dict)
325 338
326 self.delete() 339 self.hide()
340 # self.delete()
327 341
328 ok_btn.callback_clicked_add( 342 ok_btn.callback_clicked_add(
329 add_torrent_cb, uri_entry, session, self.add_dict) 343 add_torrent_cb, self.uri_entry, session, self.add_dict)
330 cancel_btn.callback_clicked_add(lambda x: self.delete()) 344 cancel_btn.callback_clicked_add(del_dialog_cb)
345 # cancel_btn.callback_clicked_add(lambda x: self.delete())
331 346
332 self.show() 347 self.show()
333 348
diff --git a/epour/gui/__init__.py b/epour/gui/__init__.py
index 548e7ce..770b8eb 100644
--- a/epour/gui/__init__.py
+++ b/epour/gui/__init__.py
@@ -89,6 +89,7 @@ if not theme_file:
89class MainInterface(object): 89class MainInterface(object):
90 90
91 def __init__(self, parent, session): 91 def __init__(self, parent, session):
92 self.add_torrent_dialog: Window = None
92 self._session = session 93 self._session = session
93 self.itc = TorrentClass(self._session, "torrent") 94 self.itc = TorrentClass(self._session, "torrent")
94 95
@@ -295,8 +296,12 @@ class MainInterface(object):
295 "torrent_finished_alert", torrent_finished_cb)) 296 "torrent_finished_alert", torrent_finished_cb))
296 297
297 def add_torrent(self, t_uri=None): 298 def add_torrent(self, t_uri=None):
298 from .TorrentSelector import TorrentSelector 299 if not self.add_torrent_dialog:
299 TorrentSelector(self.win, self._session, t_uri) 300 from .TorrentSelector import TorrentSelector
301 self.add_torrent_dialog = TorrentSelector(self.win, self._session, t_uri)
302 else:
303 self.add_torrent_dialog.uri_entry.entry_set("")
304 self.add_torrent_dialog.show()
300 305
301 def run_mainloop(self): 306 def run_mainloop(self):
302 self.win.show() 307 self.win.show()
@@ -309,6 +314,8 @@ class MainInterface(object):
309 elm.run() 314 elm.run()
310 315
311 def stop_mainloop(self): 316 def stop_mainloop(self):
317 if self.add_torrent_dialog:
318 self.add_torrent_dialog.delete()
312 elm.exit() 319 elm.exit()
313 320
314 def update(self): 321 def update(self):