mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 11:17:53 +01:00
[BugReport]Fix hang when bug report is launched (#28506)
* fix hang when bug report is launched from flyout * Normalize output dir for release
This commit is contained in:
committed by
GitHub
parent
51906e68a4
commit
b8a83fba1b
@@ -14,7 +14,7 @@
|
|||||||
"PowerToys.exe",
|
"PowerToys.exe",
|
||||||
"PowerToys.FilePreviewCommon.dll",
|
"PowerToys.FilePreviewCommon.dll",
|
||||||
"PowerToys.Interop.dll",
|
"PowerToys.Interop.dll",
|
||||||
"BugReportTool\\PowerToys.BugReportTool.exe",
|
"Tools\\PowerToys.BugReportTool.exe",
|
||||||
"WebcamReportTool\\PowerToys.WebcamReportTool.exe",
|
"WebcamReportTool\\PowerToys.WebcamReportTool.exe",
|
||||||
"StylesReportTool\\PowerToys.StylesReportTool.exe",
|
"StylesReportTool\\PowerToys.StylesReportTool.exe",
|
||||||
"Telemetry.dll",
|
"Telemetry.dll",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
|
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
|
||||||
<RegistryValue Type="string" Name="BugReportTool_exe" Value="" KeyPath="yes"/>
|
<RegistryValue Type="string" Name="BugReportTool_exe" Value="" KeyPath="yes"/>
|
||||||
</RegistryKey>
|
</RegistryKey>
|
||||||
<File Source="$(var.BinDir)BugReportTool\PowerToys.BugReportTool.exe" Id="BugReportTool.exe" Checksum="yes" />
|
<File Source="$(var.BinDir)Tools\PowerToys.BugReportTool.exe" Id="BugReportTool.exe" Checksum="yes" />
|
||||||
</Component>
|
</Component>
|
||||||
<Component Id="WebcamReportTool_exe" Win64="yes" Guid="41D5209F-7A9A-4DF2-A22A-9F0A9CF5AA63">
|
<Component Id="WebcamReportTool_exe" Win64="yes" Guid="41D5209F-7A9A-4DF2-A22A-9F0A9CF5AA63">
|
||||||
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
|
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
|
||||||
|
|||||||
33
src/runner/bug_report.cpp
Normal file
33
src/runner/bug_report.cpp
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "bug_report.h"
|
||||||
|
#include "Generated files/resource.h"
|
||||||
|
#include <common/utils/process_path.h>
|
||||||
|
#include <common/utils/resources.h>
|
||||||
|
|
||||||
|
std::atomic_bool isBugReportThreadRunning = false;
|
||||||
|
|
||||||
|
void launch_bug_report() noexcept
|
||||||
|
{
|
||||||
|
std::wstring bug_report_path = get_module_folderpath();
|
||||||
|
bug_report_path += L"\\Tools\\PowerToys.BugReportTool.exe";
|
||||||
|
|
||||||
|
bool expected_isBugReportThreadRunning = false;
|
||||||
|
if (isBugReportThreadRunning.compare_exchange_strong(expected_isBugReportThreadRunning, true))
|
||||||
|
{
|
||||||
|
std::thread([bug_report_path]() {
|
||||||
|
SHELLEXECUTEINFOW sei{ sizeof(sei) };
|
||||||
|
sei.fMask = { SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NO_CONSOLE };
|
||||||
|
sei.lpFile = bug_report_path.c_str();
|
||||||
|
sei.nShow = SW_HIDE;
|
||||||
|
if (ShellExecuteExW(&sei))
|
||||||
|
{
|
||||||
|
WaitForSingleObject(sei.hProcess, INFINITE);
|
||||||
|
CloseHandle(sei.hProcess);
|
||||||
|
static const std::wstring bugreport_success = GET_RESOURCE_STRING(IDS_BUGREPORT_SUCCESS);
|
||||||
|
MessageBoxW(nullptr, bugreport_success.c_str(), L"PowerToys", MB_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
isBugReportThreadRunning.store(false);
|
||||||
|
}).detach();
|
||||||
|
}
|
||||||
|
}
|
||||||
3
src/runner/bug_report.h
Normal file
3
src/runner/bug_report.h
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void launch_bug_report() noexcept;
|
||||||
@@ -48,6 +48,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\common\interop\two_way_pipe_message_ipc.cpp" />
|
<ClCompile Include="..\common\interop\two_way_pipe_message_ipc.cpp" />
|
||||||
<ClCompile Include="auto_start_helper.cpp" />
|
<ClCompile Include="auto_start_helper.cpp" />
|
||||||
|
<ClCompile Include="bug_report.cpp" />
|
||||||
<ClCompile Include="centralized_hotkeys.cpp" />
|
<ClCompile Include="centralized_hotkeys.cpp" />
|
||||||
<ClCompile Include="general_settings.cpp" />
|
<ClCompile Include="general_settings.cpp" />
|
||||||
<ClCompile Include="pch.cpp">
|
<ClCompile Include="pch.cpp">
|
||||||
@@ -67,6 +68,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="ActionRunnerUtils.h" />
|
<ClInclude Include="ActionRunnerUtils.h" />
|
||||||
<ClInclude Include="auto_start_helper.h" />
|
<ClInclude Include="auto_start_helper.h" />
|
||||||
|
<ClInclude Include="bug_report.h" />
|
||||||
<ClInclude Include="centralized_hotkeys.h" />
|
<ClInclude Include="centralized_hotkeys.h" />
|
||||||
<ClInclude Include="general_settings.h" />
|
<ClInclude Include="general_settings.h" />
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
|
|||||||
@@ -42,6 +42,9 @@
|
|||||||
<ClCompile Include="centralized_hotkeys.cpp">
|
<ClCompile Include="centralized_hotkeys.cpp">
|
||||||
<Filter>Utils</Filter>
|
<Filter>Utils</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="bug_report.cpp">
|
||||||
|
<Filter>Utils</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
@@ -87,6 +90,9 @@
|
|||||||
<ClInclude Include="centralized_hotkeys.h">
|
<ClInclude Include="centralized_hotkeys.h">
|
||||||
<Filter>Utils</Filter>
|
<Filter>Utils</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="bug_report.h">
|
||||||
|
<Filter>Utils</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Utils">
|
<Filter Include="Utils">
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <common/updating/updateState.h>
|
#include <common/updating/updateState.h>
|
||||||
#include <common/themes/windows_colors.h>
|
#include <common/themes/windows_colors.h>
|
||||||
#include "settings_window.h"
|
#include "settings_window.h"
|
||||||
|
#include "bug_report.h"
|
||||||
|
|
||||||
#define BUFSIZE 1024
|
#define BUFSIZE 1024
|
||||||
|
|
||||||
@@ -222,19 +223,7 @@ void dispatch_received_json(const std::wstring& json_to_parse)
|
|||||||
}
|
}
|
||||||
else if (name == L"bugreport")
|
else if (name == L"bugreport")
|
||||||
{
|
{
|
||||||
std::wstring bug_report_path = get_module_folderpath();
|
launch_bug_report();
|
||||||
bug_report_path += L"\\Tools\\PowerToys.BugReportTool.exe";
|
|
||||||
SHELLEXECUTEINFOW sei{ sizeof(sei) };
|
|
||||||
sei.fMask = { SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NO_CONSOLE };
|
|
||||||
sei.lpFile = bug_report_path.c_str();
|
|
||||||
sei.nShow = SW_HIDE;
|
|
||||||
if (ShellExecuteExW(&sei))
|
|
||||||
{
|
|
||||||
WaitForSingleObject(sei.hProcess, INFINITE);
|
|
||||||
CloseHandle(sei.hProcess);
|
|
||||||
static const std::wstring bugreport_success = GET_RESOURCE_STRING(IDS_BUGREPORT_SUCCESS);
|
|
||||||
MessageBoxW(nullptr, bugreport_success.c_str(), L"PowerToys", MB_OK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (name == L"killrunner")
|
else if (name == L"killrunner")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,17 +6,18 @@
|
|||||||
#include "centralized_kb_hook.h"
|
#include "centralized_kb_hook.h"
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
#include <common/utils/process_path.h>
|
|
||||||
#include <common/utils/resources.h>
|
#include <common/utils/resources.h>
|
||||||
#include <common/version/version.h>
|
#include <common/version/version.h>
|
||||||
#include <common/logger/logger.h>
|
#include <common/logger/logger.h>
|
||||||
#include <common/utils/elevation.h>
|
#include <common/utils/elevation.h>
|
||||||
|
#include "bug_report.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
HWND tray_icon_hwnd = NULL;
|
HWND tray_icon_hwnd = NULL;
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
wm_icon_notify = WM_APP,
|
wm_icon_notify = WM_APP,
|
||||||
wm_run_on_main_ui_thread,
|
wm_run_on_main_ui_thread,
|
||||||
};
|
};
|
||||||
@@ -44,8 +45,6 @@ struct run_on_main_ui_thread_msg
|
|||||||
PVOID data;
|
PVOID data;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::atomic_bool isBugReportThreadRunning = false;
|
|
||||||
|
|
||||||
bool dispatch_run_on_main_ui_thread(main_loop_callback_function _callback, PVOID data)
|
bool dispatch_run_on_main_ui_thread(main_loop_callback_function _callback, PVOID data)
|
||||||
{
|
{
|
||||||
if (tray_icon_hwnd == NULL)
|
if (tray_icon_hwnd == NULL)
|
||||||
@@ -97,29 +96,7 @@ void handle_tray_command(HWND window, const WPARAM command_id, LPARAM lparam)
|
|||||||
break;
|
break;
|
||||||
case ID_REPORT_BUG_COMMAND:
|
case ID_REPORT_BUG_COMMAND:
|
||||||
{
|
{
|
||||||
std::wstring bug_report_path = get_module_folderpath();
|
launch_bug_report();
|
||||||
bug_report_path += L"\\Tools\\PowerToys.BugReportTool.exe";
|
|
||||||
|
|
||||||
bool expected_isBugReportThreadRunning = false;
|
|
||||||
if (isBugReportThreadRunning.compare_exchange_strong(expected_isBugReportThreadRunning, true))
|
|
||||||
{
|
|
||||||
std::thread([bug_report_path]() {
|
|
||||||
SHELLEXECUTEINFOW sei{ sizeof(sei) };
|
|
||||||
sei.fMask = { SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NO_CONSOLE };
|
|
||||||
sei.lpFile = bug_report_path.c_str();
|
|
||||||
sei.nShow = SW_HIDE;
|
|
||||||
if (ShellExecuteExW(&sei))
|
|
||||||
{
|
|
||||||
WaitForSingleObject(sei.hProcess, INFINITE);
|
|
||||||
CloseHandle(sei.hProcess);
|
|
||||||
static const std::wstring bugreport_success = GET_RESOURCE_STRING(IDS_BUGREPORT_SUCCESS);
|
|
||||||
MessageBoxW(nullptr, bugreport_success.c_str(), L"PowerToys", MB_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
isBugReportThreadRunning.store(false);
|
|
||||||
}).detach();
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using Microsoft.PowerToys.Telemetry;
|
|||||||
using Microsoft.UI.Xaml;
|
using Microsoft.UI.Xaml;
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
using Microsoft.UI.Xaml.Media.Animation;
|
using Microsoft.UI.Xaml.Media.Animation;
|
||||||
|
using WinUIEx;
|
||||||
|
|
||||||
namespace Microsoft.PowerToys.Settings.UI.Flyout
|
namespace Microsoft.PowerToys.Settings.UI.Flyout
|
||||||
{
|
{
|
||||||
@@ -141,6 +142,9 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
|
|||||||
private void ReportBugBtn_Click(object sender, RoutedEventArgs e)
|
private void ReportBugBtn_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ViewModel.StartBugReport();
|
ViewModel.StartBugReport();
|
||||||
|
|
||||||
|
// Closing manually the flyout since no window will steal the focus
|
||||||
|
App.GetFlyoutWindow()?.Hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props')" />
|
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props')" />
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
@@ -15,15 +15,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<OutDir>$(SolutionDir)..\..\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
|
||||||
<TargetName>PowerToys.$(ProjectName)</TargetName>
|
<TargetName>PowerToys.$(ProjectName)</TargetName>
|
||||||
|
<OutDir>$(SolutionDir)..\..\$(Platform)\$(Configuration)\Tools\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
|
||||||
<TargetName>PowerToys.$(ProjectName)</TargetName>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="Shared">
|
<ImportGroup Label="Shared">
|
||||||
|
|||||||
Reference in New Issue
Block a user