/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/runner/bug_report.cpp
84 строки
2 KB
Niels Laute
Add progress/result window to the Bug Report flow with a GitHub issue shortcut (#48980)
07 авг 2026, 11:08
Не верифицирован
07 авг 2026, 11:08
9df98bd
Код
Авторство
О чём код?
#include "pch.h" #include "bug_report.h" #include "bug_report_dialog.h" #include "Generated files/resource.h" #include <common/utils/process_path.h> #include <common/utils/resources.h> BugReportManager& BugReportManager::instance() { static BugReportManager instance; return instance; } void BugReportManager::register_callback(const BugReportCallback& callback) { std::lock_guard<std::mutex> lock(m_callbacksMutex); m_callbacks.push_back(callback); } void BugReportManager::clear_callbacks() { std::lock_guard<std::mutex> lock(m_callbacksMutex); m_callbacks.clear(); } void BugReportManager::notify_observers(bool isRunning) { std::lock_guard<std::mutex> lock(m_callbacksMutex); for (const auto& callback : m_callbacks) { try { callback(isRunning); } catch (...) { // Ignore callback exceptions to prevent one bad callback from affecting others } } } void BugReportManager::launch_bug_report() noexcept { std::wstring bug_report_path = get_module_folderpath(); bug_report_path += L"\\Tools\\PowerToys.BugReportTool.exe"; bool expected_isBugReportRunning = false; if (m_isBugReportRunning.compare_exchange_strong(expected_isBugReportRunning, true)) { // Notify observers that bug report is starting notify_observers(true); std::thread([this, bug_report_path]() { // Shows the progress/result window and runs the tool. The running // state is cleared as soon as the tool process exits, so the window // with the result and "Report on GitHub" action can stay open // afterwards without keeping the UI in a "running" state. run_bug_report_dialog(bug_report_path, [this]() { m_isBugReportRunning.store(false); notify_observers(false); }); }).detach(); } else { notify_observers(false); } } bool BugReportManager::is_bug_report_running() const noexcept { return m_isBugReportRunning.load(); } // Legacy functions for backward compatibility void launch_bug_report() noexcept { BugReportManager::instance().launch_bug_report(); } bool is_bug_report_running() noexcept { return BugReportManager::instance().is_bug_report_running(); }