From a361a32f4b18ccfa1d281f1849279af7a66ce6f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 29 May 2025 13:39:33 +0200 Subject: [PATCH] More minor cleanups --- Common/StringUtils.cpp | 2 +- UI/MainScreen.cpp | 2 +- UI/MemStickScreen.cpp | 17 ++++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Common/StringUtils.cpp b/Common/StringUtils.cpp index d04311906f..8ea4e4d02c 100644 --- a/Common/StringUtils.cpp +++ b/Common/StringUtils.cpp @@ -95,7 +95,7 @@ bool containsNoCase(std::string_view haystack, std::string_view needle) { return found != haystack.end(); } -int countChar(std::string_view haystack, char needle) { +int CountChar(std::string_view haystack, char needle) { int count = 0; for (int i = 0; i < (int)haystack.size(); i++) { if (haystack[i] == needle) { diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index ba95b27f70..760eabd525 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1253,7 +1253,7 @@ void MainScreen::CreateViews() { if (versionString[0] == 'v' && isdigit(versionString[1])) { versionString = versionString.substr(1); } - if (countChar(versionString, '-') == 2) { + if (CountChar(versionString, '-') == 2) { // Shorten the commit hash. size_t cutPos = versionString.find_last_of('-') + 8; versionString = versionString.substr(0, std::min(cutPos, versionString.size())); diff --git a/UI/MemStickScreen.cpp b/UI/MemStickScreen.cpp index 392e1faf8d..de313c94a3 100644 --- a/UI/MemStickScreen.cpp +++ b/UI/MemStickScreen.cpp @@ -474,6 +474,13 @@ ConfirmMemstickMoveScreen::ConfirmMemstickMoveScreen(const Path &newMemstickFold if (initialSetup_) { moveData_ = false; } + + newSpaceTask_ = Promise::Spawn(&g_threadManager, [newMemstickFolder]() -> SpaceResult * { + int64_t freeSpaceNew; + INFO_LOG(Log::System, "Computing free space in '%s'", newMemstickFolder.c_str()); + free_disk_space(newMemstickFolder, freeSpaceNew); + return new SpaceResult{ freeSpaceNew }; + }, TaskType::IO_BLOCKING, TaskPriority::HIGH); } ConfirmMemstickMoveScreen::~ConfirmMemstickMoveScreen() { @@ -515,14 +522,6 @@ void ConfirmMemstickMoveScreen::CreateViews() { // TODO: Add spinner newFreeSpaceView_ = leftColumn->Add(new TextView(ApplySafeSubstitutions("%1: ...", ms->T("Free space")), ALIGN_LEFT, false)); - Path newMemstickFolder = newMemstickFolder_; - newSpaceTask_ = Promise::Spawn(&g_threadManager, [newMemstickFolder]() -> SpaceResult * { - int64_t freeSpaceNew; - INFO_LOG(Log::System, "Computing free space in %s", newMemstickFolder.c_str()); - free_disk_space(newMemstickFolder, freeSpaceNew); - return new SpaceResult{ freeSpaceNew }; - }, TaskType::IO_BLOCKING, TaskPriority::HIGH); - if (existingFilesInNewFolder_) { leftColumn->Add(new NoticeView(NoticeLevel::SUCCESS, ms->T("Already contains PSP data"), "")); if (!moveData_) { @@ -621,7 +620,7 @@ UI::EventReturn ConfirmMemstickMoveScreen::OnConfirm(UI::EventParams ¶ms) { Path moveSrc = g_Config.memStickDirectory; Path moveDest = newMemstickFolder_; MoveResult *result = MoveDirectoryContentsSafe(moveSrc, moveDest, progressReporter_); - NOTICE_LOG(Log::System, "Move task finished: %b", result != nullptr); + NOTICE_LOG(Log::System, "Move task finished: %d", (int)(result != nullptr)); return result; }, TaskType::IO_BLOCKING, TaskPriority::HIGH);