chore: abstract cancel check function to controller
Some checks failed
Mirror to Codeberg / mirror-to-codeberg (push) Has been cancelled

This commit is contained in:
aclist 2026-06-05 22:39:13 +09:00
parent b615869278
commit 9fa2840d1b
3 changed files with 15 additions and 30 deletions

View File

@ -525,3 +525,13 @@ class Controller(GObject.GObject):
def present_window(self) -> None:
self.mediator.window.present_with_time(Gdk.CURRENT_TIME)
def is_cancel_pending(self) -> bool:
if self.get_exit_event().is_set():
return True
if self.get_cancel_event().is_set():
self.clear_cancel_event()
return True
return False

View File

@ -278,11 +278,9 @@ class ConnectionManager:
self.thread_man.show_cancel(False)
self.thread_man.update_dialog(waiting_for_launch)
while True:
if self.is_cancel_pending():
if self.controller.is_cancel_pending():
# TODO: some facility to also close spawned steam process
return
# if self.controller.get_exit_event().is_set():
# return
if is_dayz_running():
break
time.sleep(1)
@ -294,27 +292,13 @@ class ConnectionManager:
self.controller.add_to_history(self.history, self.record)
self.controller.open_page(NotebookPage.SERVERS)
def is_cancel_pending(self) -> bool:
if self.controller.get_exit_event().is_set():
return True
if self.controller.get_cancel_event().is_set():
self.controller.clear_cancel_event()
return True
return False
def _update_mods(self, raise_window: bool, menu_only: bool = False) -> None:
# NOTE: fast enqueue all mods in auto mode
prefs = self.controller.get_prefs()
for title, mod, stamp, size in self.missing_mods:
if self.is_cancel_pending():
if self.controller.is_cancel_pending():
return
# TODO: check cancel and exit events
# if self.controller.get_exit_event().is_set():
# return
# if self.controller.get_cancel_event().is_set():
# self.controller.clear_cancel_event()
# return
enqueue_mod(mod, self.appid)
time.sleep(3)
@ -327,17 +311,12 @@ class ConnectionManager:
# NOTE: Steam updates mod chunks in parallel, will finish at the same time
while mod_path.is_dir() is False:
if self.is_cancel_pending():
if self.controller.is_cancel_pending():
return
time.sleep(1)
while True:
if self.is_cancel_pending():
if self.controller.is_cancel_pending():
return
# if self.controller.get_exit_event().is_set():
# return
# if self.controller.get_cancel_event().is_set():
# self.controller.clear_cancel_event()
# return
cur_size = get_mod_dir_size(mod_path)
if cur_size == size:
break

View File

@ -138,13 +138,9 @@ class ServerModelManager:
futures = [executor.submit(Servers.test_ip, i, port, event) for i in ports]
for future in as_completed(futures):
try:
if self.controller.get_exit_event().is_set():
if self.controller.is_cancel_pending():
event.set()
return
if self.controller.get_cancel_event().is_set():
event.set()
self.controller.clear_cancel_event()
return
res = future.result(timeout=LAN_TIMEOUT)
if res is None:
continue