From 54593940e7fc6fb037bee7445db4965b8e1be29a Mon Sep 17 00:00:00 2001 From: El Thoro Date: Tue, 18 Aug 2026 22:46:18 +0200 Subject: [PATCH 1/3] Forward Flameshot return value to windows-cli; set UTF8 for console output. (#4888) --- src/windows-cli.cpp | 72 ++++++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/src/windows-cli.cpp b/src/windows-cli.cpp index 267974a1fc..ad7c0d9743 100644 --- a/src/windows-cli.cpp +++ b/src/windows-cli.cpp @@ -1,3 +1,6 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors + #include #include #include @@ -38,12 +41,17 @@ static void appendQuotedArg(std::wstring& cmdline, const std::wstring& arg) // forwarding each argument as literal data. flameshot.exe is passed via // lpApplicationName so no command interpreter is involved and shell // metacharacters have no effect. When wait is true, the child's stdout is -// captured and relayed. -void CallFlameshot(int argc, wchar_t* argv[], bool wait) +// captured and relayed. Returns child's process exit code. If wait==false, +// returns 0 (child running). +int CallFlameshot(int argc, wchar_t* argv[], bool wait) { // Full path to flameshot.exe, in the same directory as this executable. wchar_t path[MAX_PATH]; - GetModuleFileNameW(NULL, path, MAX_PATH); + DWORD len = GetModuleFileNameW(NULL, path, MAX_PATH); + if (len == 0 || len == MAX_PATH) { + return static_cast(GetLastError()); + } + std::wstring pathstring(path); size_t lastBackslash = pathstring.find_last_of(L'\\'); std::wstring directory = (lastBackslash != std::wstring::npos) @@ -70,7 +78,7 @@ void CallFlameshot(int argc, wchar_t* argv[], bool wait) sa.nLength = sizeof(sa); sa.bInheritHandle = TRUE; if (!CreatePipe(&readEnd, &writeEnd, &sa, 0)) { - return; + return static_cast(GetLastError()); } SetHandleInformation(readEnd, HANDLE_FLAG_INHERIT, 0); @@ -81,51 +89,75 @@ void CallFlameshot(int argc, wchar_t* argv[], bool wait) } PROCESS_INFORMATION pi{}; - BOOL ok = CreateProcessW(exePath.c_str(), - mutableCmd.data(), - NULL, - NULL, - wait ? TRUE : FALSE, - 0, - NULL, - NULL, - &si, - &pi); + BOOL ok = CreateProcessW( + exePath.c_str(), + mutableCmd.data(), + NULL, + NULL, + wait ? TRUE : FALSE, // only inherit handles when we created a pipe + 0, + NULL, + NULL, + &si, + &pi); if (writeEnd) { CloseHandle(writeEnd); + writeEnd = NULL; } + if (!ok) { if (readEnd) { CloseHandle(readEnd); } - return; + return static_cast(GetLastError()); } + int exitCode = 0; + if (wait) { + // Read child's stdout/stderr + SetConsoleOutputCP(CP_UTF8); + SetConsoleCP(CP_UTF8); char buffer[2048]; DWORD n = 0; while (ReadFile(readEnd, buffer, sizeof(buffer), &n, NULL) && n > 0) { std::cout.write(buffer, n); } CloseHandle(readEnd); + readEnd = NULL; + WaitForSingleObject(pi.hProcess, INFINITE); + DWORD code = 0; + if (GetExitCodeProcess(pi.hProcess, &code)) { + exitCode = static_cast(code); + } else { + exitCode = static_cast(GetLastError()); + } + } else { + // Not waiting: Exit code can't be known + exitCode = 0; } CloseHandle(pi.hProcess); CloseHandle(pi.hThread); + + return exitCode; } // Console 'wrapper' for flameshot on windows int wmain(int argc, wchar_t* argv[]) { - // if no args, do not wait for stdout + // if no args, do not wait for stdout => return 0. + // If args exist, wait and return flameshot's exit code. if (argc == 1) { std::cout << "Starting flameshot in daemon mode" << std::endl; - CallFlameshot(argc, argv, false); + int code = CallFlameshot(argc, argv, false); + std::cout.flush(); + return code; } else { - CallFlameshot(argc, argv, true); + int code = CallFlameshot(argc, argv, true); + std::cout.flush(); + return code; } - std::cout.flush(); - return 0; } From 6abe2a9f1e81c67ff18d77e066d847673f0d05d9 Mon Sep 17 00:00:00 2001 From: "Weblate (bot)" Date: Tue, 18 Aug 2026 22:46:38 +0200 Subject: [PATCH 2/3] Translations update from Hosted Weblate (#4884) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Translated using Weblate (Japanese) Currently translated at 100.0% (472 of 472 strings) Translation: Flameshot/Flameshot Translate-URL: https://hosted.weblate.org/projects/flameshot/flameshot/ja/ * Translated using Weblate (Japanese) Currently translated at 100.0% (472 of 472 strings) Translation: Flameshot/Flameshot Translate-URL: https://hosted.weblate.org/projects/flameshot/flameshot/ja/ * Translated using Weblate (Vietnamese) Currently translated at 91.9% (434 of 472 strings) Translation: Flameshot/Flameshot Translate-URL: https://hosted.weblate.org/projects/flameshot/flameshot/vi/ --------- Co-authored-by: Rukoto Luther Co-authored-by: coolvitto Co-authored-by: Nguyễn Duy Khoa --- data/translations/Internationalization_vi.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/translations/Internationalization_vi.ts b/data/translations/Internationalization_vi.ts index 96d96da8cf..7b835c8bff 100644 --- a/data/translations/Internationalization_vi.ts +++ b/data/translations/Internationalization_vi.ts @@ -127,12 +127,12 @@ Full Screen - + Toàn Màn Hình Monitor %1: %2 (%3x%4) - + Màn hình %1: %2 (%3x%4) Full Screen (All Monitors) @@ -193,7 +193,7 @@ Monitor: - + Màn hình: @@ -1356,7 +1356,7 @@ Vui lòng xử lí chúng thủ công trong tệp cấu hình. Capture active monitor (skip monitor selection) - + Chụp màn hình đang hoạt động (bỏ quả bước chọn màn hình) From 71bb194394ab49dee60cad72a3904d3225154ef5 Mon Sep 17 00:00:00 2001 From: dion <23h13.joshua@sjec.ac.in> Date: Wed, 19 Aug 2026 02:20:54 +0530 Subject: [PATCH 3/3] perf: insert button list in sorted order instead of re-sorting, complete the TODO left (#4867) --- src/config/buttonlistview.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/config/buttonlistview.cpp b/src/config/buttonlistview.cpp index 0ac506aef6..2e64d52f98 100644 --- a/src/config/buttonlistview.cpp +++ b/src/config/buttonlistview.cpp @@ -52,13 +52,14 @@ void ButtonListView::updateActiveButtons(QListWidgetItem* item) { CaptureTool::Type bType = m_buttonTypeByName[item->text()]; if (item->checkState() == Qt::Checked) { - m_listButtons.append(bType); - // TODO refactor so we don't need external sorts + // Refactored to avoid external sort: insert into the correct position using bt = CaptureTool::Type; - std::sort(m_listButtons.begin(), m_listButtons.end(), [](bt a, bt b) { - return CaptureToolButton::getPriorityByButton(a) < - CaptureToolButton::getPriorityByButton(b); - }); + auto it = std::lower_bound( + m_listButtons.begin(), m_listButtons.end(), bType, [](bt a, bt b) { + return CaptureToolButton::getPriorityByButton(a) < + CaptureToolButton::getPriorityByButton(b); + }); + m_listButtons.insert(it, bType); } else { m_listButtons.removeOne(bType); }