mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-18 05:28:07 +08:00
[KBM Editor] Catch UpdateLayout exceptions (#13635)
This commit is contained in:
parent
805d8d81c5
commit
68c199aa64
@ -354,7 +354,14 @@ inline void CreateEditKeyboardWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMan
|
||||
xamlContainer.Children().Append(header);
|
||||
xamlContainer.Children().Append(helperText);
|
||||
xamlContainer.Children().Append(scrollViewer);
|
||||
try
|
||||
{
|
||||
// If a layout update has been triggered by other methods (e.g.: adapting to zoom level), this may throw an exception.
|
||||
xamlContainer.UpdateLayout();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
desktopSource.Content(xamlContainer);
|
||||
////End XAML Island section
|
||||
|
@ -325,7 +325,14 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa
|
||||
xamlContainer.Children().Append(header);
|
||||
xamlContainer.Children().Append(helperText);
|
||||
xamlContainer.Children().Append(scrollViewer);
|
||||
try
|
||||
{
|
||||
// If a layout update has been triggered by other methods (e.g.: adapting to zoom level), this may throw an exception.
|
||||
xamlContainer.UpdateLayout();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
desktopSource.Content(xamlContainer);
|
||||
|
||||
|
@ -171,8 +171,22 @@ void KeyboardManagerState::UpdateDetectShortcutUI()
|
||||
AddKeyToLayout(currentShortcutUI2.as<StackPanel>(), shortcut[i]);
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
// If a layout update has been triggered by other methods (e.g.: adapting to zoom level), this may throw an exception.
|
||||
currentShortcutUI1.as<StackPanel>().UpdateLayout();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
// If a layout update has been triggered by other methods (e.g.: adapting to zoom level), this may throw an exception.
|
||||
currentShortcutUI2.as<StackPanel>().UpdateLayout();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -189,7 +203,14 @@ void KeyboardManagerState::UpdateDetectSingleKeyRemapUI()
|
||||
currentSingleKeyUI.as<StackPanel>().Children().Clear();
|
||||
hstring key = winrt::to_hstring(keyboardMap.GetKeyName(detectedRemapKey).c_str());
|
||||
AddKeyToLayout(currentSingleKeyUI.as<StackPanel>(), key);
|
||||
try
|
||||
{
|
||||
// If a layout update has been triggered by other methods (e.g.: adapting to zoom level), this may throw an exception.
|
||||
currentSingleKeyUI.as<StackPanel>().UpdateLayout();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,14 @@ ShortcutControl::ShortcutControl(StackPanel table, StackPanel row, const int col
|
||||
shortcutControlLayout.as<StackPanel>().Children().Append(typeShortcut.as<Button>());
|
||||
shortcutControlLayout.as<StackPanel>().Children().Append(shortcutDropDownStackPanel.as<StackPanel>());
|
||||
KeyDropDownControl::AddDropDown(table, row, shortcutDropDownStackPanel.as<StackPanel>(), colIndex, shortcutRemapBuffer, keyDropDownControlObjects, targetApp, isHybridControl, false);
|
||||
try
|
||||
{
|
||||
// If a layout update has been triggered by other methods (e.g.: adapting to zoom level), this may throw an exception.
|
||||
shortcutControlLayout.as<StackPanel>().UpdateLayout();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Function to set the accessible name of the target App text box
|
||||
@ -480,7 +487,14 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
|
||||
buttonPanel.Children().Append(cancelButton);
|
||||
|
||||
stackPanel.Children().Append(buttonPanel);
|
||||
try
|
||||
{
|
||||
// If a layout update has been triggered by other methods (e.g.: adapting to zoom level), this may throw an exception.
|
||||
stackPanel.UpdateLayout();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
// Configure the keyboardManagerState to store the UI information.
|
||||
keyboardManagerState.ConfigureDetectShortcutUI(keyStackPanel1, keyStackPanel2);
|
||||
|
@ -56,7 +56,14 @@ SingleKeyRemapControl::SingleKeyRemapControl(StackPanel table, StackPanel row, c
|
||||
}
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
// If a layout update has been triggered by other methods (e.g.: adapting to zoom level), this may throw an exception.
|
||||
singleKeyRemapControlLayout.as<StackPanel>().UpdateLayout();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Function to set the accessible names for all the controls in a row
|
||||
@ -168,7 +175,14 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(StackPanel& parent, std::ve
|
||||
}
|
||||
|
||||
children.RemoveAt(rowIndex);
|
||||
try
|
||||
{
|
||||
// If a layout update has been triggered by other methods (e.g.: adapting to zoom level), this may throw an exception.
|
||||
parent.UpdateLayout();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
singleKeyRemapBuffer.erase(singleKeyRemapBuffer.begin() + rowIndex);
|
||||
|
||||
// delete the SingleKeyRemapControl objects so that they get destructed
|
||||
@ -183,7 +197,14 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(StackPanel& parent, std::ve
|
||||
deleteRemapKeystoolTip.Content(box_value(GET_RESOURCE_STRING(IDS_DELETE_REMAPPING_BUTTON)));
|
||||
ToolTipService::SetToolTip(deleteRemapKeys, deleteRemapKeystoolTip);
|
||||
row.Children().Append(deleteRemapKeys);
|
||||
try
|
||||
{
|
||||
// If a layout update has been triggered by other methods (e.g.: adapting to zoom level), this may throw an exception.
|
||||
parent.UpdateLayout();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
// Set accessible names
|
||||
UpdateAccessibleNames(keyboardRemapControlObjects.back()[0]->getSingleKeyRemapControl(), keyboardRemapControlObjects.back()[1]->getSingleKeyRemapControl(), deleteRemapKeys, (int)keyboardRemapControlObjects.size());
|
||||
@ -362,7 +383,14 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
|
||||
buttonPanel.Children().Append(cancelButton);
|
||||
|
||||
stackPanel.Children().Append(buttonPanel);
|
||||
try
|
||||
{
|
||||
// If a layout update has been triggered by other methods (e.g.: adapting to zoom level), this may throw an exception.
|
||||
stackPanel.UpdateLayout();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
// Configure the keyboardManagerState to store the UI information.
|
||||
keyboardManagerState.ConfigureDetectSingleKeyRemapUI(keyStackPanel);
|
||||
|
Loading…
Reference in New Issue
Block a user