From b6f824a313731dca164f0d02e032869b31c1bae1 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 24 May 2024 11:43:39 -0400 Subject: [PATCH] Browser: Don't assume downloads have a "total size" available Ran into a crash here while testing LibProtocol changes. The method we invoke here (did_progress) already accepts an Optional, and handles when that Optional is empty. So there's no need to assume `total_size` is non-empty. --- Userland/Applications/Browser/DownloadWidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Applications/Browser/DownloadWidget.cpp b/Userland/Applications/Browser/DownloadWidget.cpp index fb4265b513..e2a51a3252 100644 --- a/Userland/Applications/Browser/DownloadWidget.cpp +++ b/Userland/Applications/Browser/DownloadWidget.cpp @@ -43,8 +43,9 @@ DownloadWidget::DownloadWidget(const URL::URL& url) m_elapsed_timer.start(); m_download = Web::ResourceLoader::the().connector().start_request("GET", url); VERIFY(m_download); + m_download->on_progress = [this](Optional total_size, u64 downloaded_size) { - did_progress(total_size.value(), downloaded_size); + did_progress(move(total_size), downloaded_size); }; {