Skip to content

Commit b40d0c4

Browse files
appstore: stop downloading icons when closing
1 parent d6e2d58 commit b40d0c4

File tree

1 file changed

+10
-5
lines changed
  • internal_filesystem/builtin/apps/com.example.appstore/assets

1 file changed

+10
-5
lines changed

internal_filesystem/builtin/apps/com.example.appstore/assets/appstore.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
please_wait_label = None
1717
app_detail_screen = None
1818
progress_bar = None
19+
keepdownloadingicons = False
1920

2021
action_label_install = "Install"
2122
action_label_uninstall = "Uninstall"
@@ -256,11 +257,13 @@ def download_apps(json_url):
256257
def download_icons():
257258
global apps
258259
for app in apps:
260+
if not keepdownloadingicons:
261+
break
259262
image_dsc = download_icon(app.icon_url)
260263
app.image_dsc = image_dsc
261264
app.image.set_src(image_dsc)
262265
print(f"Changed image_dsc for {app.icon_url}")
263-
print("finished downloading all icons")
266+
print("download_icons exiting")
264267

265268
def load_icon(icon_path):
266269
with open(icon_path, 'rb') as f:
@@ -312,7 +315,9 @@ def create_apps_list():
312315
desc_label.add_event_cb(lambda e, a=app: show_app_detail(a), lv.EVENT.CLICKED, None)
313316
print("create_apps_list app done")
314317
try:
315-
_thread.stack_size(16384)
318+
global keepdownloadingicons
319+
keepdownloadingicons = True
320+
_thread.stack_size(12*1024)
316321
_thread.start_new_thread(download_icons,())
317322
except Exception as e:
318323
print("Could not start thread to download icons: ", e)
@@ -403,14 +408,14 @@ def toggle_install(download_url, fullname):
403408
label_text = install_label.get_text()
404409
if label_text == action_label_install:
405410
try:
406-
_thread.stack_size(16384)
411+
_thread.stack_size(12*1024)
407412
_thread.start_new_thread(download_and_unzip, (download_url, f"/apps/{fullname}", fullname))
408413
except Exception as e:
409414
print("Could not start download_and_unzip thread: ", e)
410415
elif label_text == action_label_uninstall or label_text == action_label_restore:
411416
print("Uninstalling app....")
412417
try:
413-
_thread.stack_size(16384)
418+
_thread.stack_size(12*1024)
414419
_thread.start_new_thread(uninstall_app, (f"/apps/{fullname}", fullname))
415420
except Exception as e:
416421
print("Could not start download_and_unzip thread: ", e)
@@ -421,7 +426,7 @@ def update_button_click(download_url, fullname):
421426
update_button.add_flag(lv.obj.FLAG.HIDDEN)
422427
install_button.set_size(lv.pct(100), 40)
423428
try:
424-
_thread.stack_size(16384)
429+
_thread.stack_size(12*1024)
425430
_thread.start_new_thread(download_and_unzip, (download_url, f"/apps/{fullname}", fullname))
426431
except Exception as e:
427432
print("Could not start download_and_unzip thread: ", e)

0 commit comments

Comments
 (0)