mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-23 19:49:17 +08: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:
parent
51906e68a4
commit
b8a83fba1b
@ -14,7 +14,7 @@
|
||||
"PowerToys.exe",
|
||||
"PowerToys.FilePreviewCommon.dll",
|
||||
"PowerToys.Interop.dll",
|
||||
"BugReportTool\\PowerToys.BugReportTool.exe",
|
||||
"Tools\\PowerToys.BugReportTool.exe",
|
||||
"WebcamReportTool\\PowerToys.WebcamReportTool.exe",
|
||||
"StylesReportTool\\PowerToys.StylesReportTool.exe",
|
||||
"Telemetry.dll",
|
||||
|
@ -10,7 +10,7 @@
|
||||
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
|
||||
<RegistryValue Type="string" Name="BugReportTool_exe" Value="" KeyPath="yes"/>
|
||||
</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 Id="WebcamReportTool_exe" Win64="yes" Guid="41D5209F-7A9A-4DF2-A22A-9F0A9CF5AA63">
|
||||
<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>
|
||||
<ClCompile Include="..\common\interop\two_way_pipe_message_ipc.cpp" />
|
||||
<ClCompile Include="auto_start_helper.cpp" />
|
||||
<ClCompile Include="bug_report.cpp" />
|
||||
<ClCompile Include="centralized_hotkeys.cpp" />
|
||||
<ClCompile Include="general_settings.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
@ -67,6 +68,7 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ActionRunnerUtils.h" />
|
||||
<ClInclude Include="auto_start_helper.h" />
|
||||
<ClInclude Include="bug_report.h" />
|
||||
<ClInclude Include="centralized_hotkeys.h" />
|
||||
<ClInclude Include="general_settings.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
|
@ -42,6 +42,9 @@
|
||||
<ClCompile Include="centralized_hotkeys.cpp">
|
||||
<Filter>Utils</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="bug_report.cpp">
|
||||
<Filter>Utils</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
@ -87,6 +90,9 @@
|
||||
<ClInclude Include="centralized_hotkeys.h">
|
||||
<Filter>Utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="bug_report.h">
|
||||
<Filter>Utils</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Utils">
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <common/updating/updateState.h>
|
||||
#include <common/themes/windows_colors.h>
|
||||
#include "settings_window.h"
|
||||
#include "bug_report.h"
|
||||
|
||||
#define BUFSIZE 1024
|
||||
|
||||
@ -108,7 +109,7 @@ std::optional<std::wstring> dispatch_json_action_to_module(const json::JsonObjec
|
||||
else if (action == L"check_for_updates")
|
||||
{
|
||||
bool expected_isUpdateCheckThreadRunning = false;
|
||||
if (isUpdateCheckThreadRunning.compare_exchange_strong(expected_isUpdateCheckThreadRunning,true))
|
||||
if (isUpdateCheckThreadRunning.compare_exchange_strong(expected_isUpdateCheckThreadRunning, true))
|
||||
{
|
||||
std::thread([]() {
|
||||
CheckForUpdatesCallback();
|
||||
@ -222,19 +223,7 @@ void dispatch_received_json(const std::wstring& json_to_parse)
|
||||
}
|
||||
else if (name == L"bugreport")
|
||||
{
|
||||
std::wstring bug_report_path = get_module_folderpath();
|
||||
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);
|
||||
}
|
||||
launch_bug_report();
|
||||
}
|
||||
else if (name == L"killrunner")
|
||||
{
|
||||
@ -410,18 +399,18 @@ void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::op
|
||||
PTSettingsHelper::save_general_settings(save_settings.to_json());
|
||||
|
||||
std::wstring executable_args = fmt::format(L"\"{}\" {} {} {} {} {} {} {} {} {} {} {}",
|
||||
executable_path,
|
||||
powertoys_pipe_name,
|
||||
settings_pipe_name,
|
||||
std::to_wstring(powertoys_pid),
|
||||
settings_theme,
|
||||
settings_elevatedStatus,
|
||||
settings_isUserAnAdmin,
|
||||
settings_showOobe,
|
||||
settings_showScoobe,
|
||||
settings_showFlyout,
|
||||
settings_containsSettingsWindow,
|
||||
settings_containsFlyoutPosition);
|
||||
executable_path,
|
||||
powertoys_pipe_name,
|
||||
settings_pipe_name,
|
||||
std::to_wstring(powertoys_pid),
|
||||
settings_theme,
|
||||
settings_elevatedStatus,
|
||||
settings_isUserAnAdmin,
|
||||
settings_showOobe,
|
||||
settings_showScoobe,
|
||||
settings_showFlyout,
|
||||
settings_containsSettingsWindow,
|
||||
settings_containsFlyoutPosition);
|
||||
|
||||
if (settings_window.has_value())
|
||||
{
|
||||
|
@ -6,17 +6,18 @@
|
||||
#include "centralized_kb_hook.h"
|
||||
#include <Windows.h>
|
||||
|
||||
#include <common/utils/process_path.h>
|
||||
#include <common/utils/resources.h>
|
||||
#include <common/version/version.h>
|
||||
#include <common/logger/logger.h>
|
||||
#include <common/utils/elevation.h>
|
||||
#include "bug_report.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
HWND tray_icon_hwnd = NULL;
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
wm_icon_notify = WM_APP,
|
||||
wm_run_on_main_ui_thread,
|
||||
};
|
||||
@ -44,8 +45,6 @@ struct run_on_main_ui_thread_msg
|
||||
PVOID data;
|
||||
};
|
||||
|
||||
std::atomic_bool isBugReportThreadRunning = false;
|
||||
|
||||
bool dispatch_run_on_main_ui_thread(main_loop_callback_function _callback, PVOID data)
|
||||
{
|
||||
if (tray_icon_hwnd == NULL)
|
||||
@ -74,11 +73,11 @@ void handle_tray_command(HWND window, const WPARAM command_id, LPARAM lparam)
|
||||
switch (command_id)
|
||||
{
|
||||
case ID_SETTINGS_MENU_COMMAND:
|
||||
{
|
||||
std::wstring settings_window{ winrt::to_hstring(ESettingsWindowNames_to_string(static_cast<ESettingsWindowNames>(lparam))) };
|
||||
open_settings_window(settings_window, false);
|
||||
}
|
||||
break;
|
||||
{
|
||||
std::wstring settings_window{ winrt::to_hstring(ESettingsWindowNames_to_string(static_cast<ESettingsWindowNames>(lparam))) };
|
||||
open_settings_window(settings_window, false);
|
||||
}
|
||||
break;
|
||||
case ID_EXIT_MENU_COMMAND:
|
||||
if (h_menu)
|
||||
{
|
||||
@ -97,29 +96,7 @@ void handle_tray_command(HWND window, const WPARAM command_id, LPARAM lparam)
|
||||
break;
|
||||
case ID_REPORT_BUG_COMMAND:
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
launch_bug_report();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -230,7 +207,7 @@ LRESULT __stdcall tray_icon_window_proc(HWND window, UINT message, WPARAM wparam
|
||||
// start timer for detecting single or double click
|
||||
double_click_timer_running = true;
|
||||
double_clicked = false;
|
||||
|
||||
|
||||
UINT doubleClickTime = GetDoubleClickTime();
|
||||
std::thread([doubleClickTime]() {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(doubleClickTime));
|
||||
|
@ -13,6 +13,7 @@ using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
using WinUIEx;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Flyout
|
||||
{
|
||||
@ -141,6 +142,9 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
|
||||
private void ReportBugBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
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">
|
||||
<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">
|
||||
@ -15,15 +15,9 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<OutDir>$(SolutionDir)..\..\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||
<TargetName>PowerToys.$(ProjectName)</TargetName>
|
||||
<OutDir>$(SolutionDir)..\..\$(Platform)\$(Configuration)\Tools\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||
<TargetName>PowerToys.$(ProjectName)</TargetName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
@ -45,7 +39,7 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\deps\cziplib\src\zip.c">
|
||||
<!-- Disabling warnings for external code -->
|
||||
<DisableSpecificWarnings>4706;26451;4267;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<DisableSpecificWarnings>4706;26451;4267;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EventViewer.cpp" />
|
||||
<ClCompile Include="InstallationFolder.cpp" />
|
||||
|
Loading…
Reference in New Issue
Block a user