forked from enlightenment/epour
The app was not able to add a torrent.
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
This commit is contained in:
parent
c7264e9ed5
commit
ef8ebed4f5
|
@ -40,6 +40,7 @@ from efl.elementary import Spinner
|
|||
# ELM_SEL_FORMAT_TEXT
|
||||
|
||||
from .Widgets import UnitSpinner
|
||||
from ..session import lt_version_post_breaking_change
|
||||
|
||||
EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
|
||||
EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
|
||||
|
@ -139,9 +140,13 @@ seed, this flag has no effect.'''
|
|||
def __init__(self, parent, session, t_uri=None):
|
||||
DialogWindow.__init__(
|
||||
self, parent, "addtorrent", _("Add Torrent"),
|
||||
size=(scale * 400, scale * 400), autodel=True
|
||||
size=(scale * 400, scale * 400), autodel=False
|
||||
)
|
||||
|
||||
def _cb_close(self):
|
||||
self.hide()
|
||||
|
||||
self.callback_delete_request_add(lambda o: _cb_close(o))
|
||||
self.add_dict = {}
|
||||
|
||||
scrol = Scroller(
|
||||
|
@ -160,20 +165,20 @@ seed, this flag has no effect.'''
|
|||
box.pack_end(hbox)
|
||||
hbox.show()
|
||||
|
||||
uri_entry = Entry(
|
||||
self.uri_entry = Entry(
|
||||
box, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ,
|
||||
single_line=True, scrollable=True
|
||||
)
|
||||
uri_entry.part_text_set("guide", _("Enter torrent file path / magnet URI / info hash"))
|
||||
self.uri_entry.part_text_set("guide", _("Enter torrent file path / magnet URI / info hash"))
|
||||
|
||||
if t_uri:
|
||||
uri_entry.entry = utf8_to_markup(t_uri)
|
||||
self.uri_entry.entry = utf8_to_markup(t_uri)
|
||||
|
||||
hbox.pack_end(uri_entry)
|
||||
uri_entry.show()
|
||||
hbox.pack_end(self.uri_entry)
|
||||
self.uri_entry.show()
|
||||
|
||||
fsb = Button(box, text=_("Select file"))
|
||||
fsb.callback_clicked_add(lambda x: TorrentFs(self, uri_entry))
|
||||
fsb.callback_clicked_add(lambda x: TorrentFs(self, self.uri_entry))
|
||||
hbox.pack_end(fsb)
|
||||
fsb.show()
|
||||
|
||||
|
@ -239,7 +244,12 @@ seed, this flag has no effect.'''
|
|||
flags = flags ^ int(add_torrent_params_flags_t.flag_auto_managed)
|
||||
self.add_dict["flags"] = flags
|
||||
|
||||
for name, flag in sorted(add_torrent_params_flags_t.names.items()):
|
||||
if lt_version_post_breaking_change:
|
||||
items = sorted(add_torrent_params_flags_t.__dict__.items())
|
||||
flags_list = [flag for flag in items if not flag[0].startswith("_")]
|
||||
else:
|
||||
flags_list = sorted(add_torrent_params_flags_t.names.items())
|
||||
for name, flag in flags_list:
|
||||
if not int(flag) in self.names.keys():
|
||||
continue
|
||||
c = Check(
|
||||
|
@ -312,6 +322,9 @@ seed, this flag has no effect.'''
|
|||
box.show()
|
||||
scrol.show()
|
||||
|
||||
def del_dialog_cb(btn):
|
||||
self.hide()
|
||||
|
||||
def add_torrent_cb(btn, uri_entry, session, add_dict):
|
||||
uri = uri_entry.entry
|
||||
|
||||
|
@ -323,11 +336,13 @@ seed, this flag has no effect.'''
|
|||
session.fill_add_dict_based_on_uri(add_dict, uri)
|
||||
session.add_torrent_with_dict(add_dict)
|
||||
|
||||
self.delete()
|
||||
self.hide()
|
||||
# self.delete()
|
||||
|
||||
ok_btn.callback_clicked_add(
|
||||
add_torrent_cb, uri_entry, session, self.add_dict)
|
||||
cancel_btn.callback_clicked_add(lambda x: self.delete())
|
||||
add_torrent_cb, self.uri_entry, session, self.add_dict)
|
||||
cancel_btn.callback_clicked_add(del_dialog_cb)
|
||||
# cancel_btn.callback_clicked_add(lambda x: self.delete())
|
||||
|
||||
self.show()
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ if not theme_file:
|
|||
class MainInterface(object):
|
||||
|
||||
def __init__(self, parent, session):
|
||||
self.add_torrent_dialog: Window = None
|
||||
self._session = session
|
||||
self.itc = TorrentClass(self._session, "torrent")
|
||||
|
||||
|
@ -295,8 +296,12 @@ class MainInterface(object):
|
|||
"torrent_finished_alert", torrent_finished_cb))
|
||||
|
||||
def add_torrent(self, t_uri=None):
|
||||
from .TorrentSelector import TorrentSelector
|
||||
TorrentSelector(self.win, self._session, t_uri)
|
||||
if not self.add_torrent_dialog:
|
||||
from .TorrentSelector import TorrentSelector
|
||||
self.add_torrent_dialog = TorrentSelector(self.win, self._session, t_uri)
|
||||
else:
|
||||
self.add_torrent_dialog.uri_entry.entry_set("")
|
||||
self.add_torrent_dialog.show()
|
||||
|
||||
def run_mainloop(self):
|
||||
self.win.show()
|
||||
|
@ -309,6 +314,8 @@ class MainInterface(object):
|
|||
elm.run()
|
||||
|
||||
def stop_mainloop(self):
|
||||
if self.add_torrent_dialog:
|
||||
self.add_torrent_dialog.delete()
|
||||
elm.exit()
|
||||
|
||||
def update(self):
|
||||
|
|
Loading…
Reference in New Issue