[Scummvm-git-logs] scummvm master -> e72135309f4c5b039023c124ba78a38132df05db

sev- noreply at scummvm.org
Sun Jan 8 14:10:22 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e72135309f GUI: Update download progress only twice a second to put less strain on CPU


Commit: e72135309f4c5b039023c124ba78a38132df05db
    https://github.com/scummvm/scummvm/commit/e72135309f4c5b039023c124ba78a38132df05db
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-01-08T15:10:14+01:00

Commit Message:
GUI: Update download progress only twice a second to put less strain on CPU

Changed paths:
    gui/downloadpacksdialog.cpp


diff --git a/gui/downloadpacksdialog.cpp b/gui/downloadpacksdialog.cpp
index f39bed3e835..dd393ff3d4b 100644
--- a/gui/downloadpacksdialog.cpp
+++ b/gui/downloadpacksdialog.cpp
@@ -56,11 +56,12 @@ struct DialogState {
 	uint32 totalFiles;
 	uint32 startTime;
 	const char *listfname;
+	uint32 lastUpdate;
 
 	DialogState(const char *fname) {
 		listfname = fname;
 		state = kDownloadStateNone;
-		downloadedSize = totalSize = totalFiles = startTime = 0;
+		downloadedSize = totalSize = totalFiles = startTime = lastUpdate = 0;
 		dialog = nullptr;
 	}
 
@@ -86,7 +87,7 @@ void DialogState::downloadList() {
 }
 
 void DialogState::proceedDownload() {
-	startTime = g_system->getMillis();
+	startTime = lastUpdate = g_system->getMillis();
 	takeOneFile();
 }
 
@@ -147,8 +148,10 @@ void DialogState::downloadFileCallback(Networking::DataResponse r) {
 		}
 	}
 
-	if (dialog)
+	if (dialog && g_system->getMillis() > lastUpdate + 500) {
+		lastUpdate = g_system->getMillis();
 		dialog->sendCommand(kDownloadProgressCmd, 0);
+	}
 }
 
 void DialogState::errorCallback(Networking::ErrorResponse error) {




More information about the Scummvm-git-logs mailing list