fix: Don't share nonfrozen Brushes across threads

Bugs (fixed):
  * Grid settings dialogs crash when multiple are opened on diff threads

  Cause: Brushes (and all Freezables) that haven't been frozen throw an ex when
  any Dependency Properties are accessed from a thread that isn't associated
  with their Dispatcher (i.e., the thread on which they were created).
This commit is contained in:
John Colvin committed 2022-08-22 16:08:40 -04:00
1 parent bbfbd0b691
commit 9bb7025752
5 files changed
+21 -3

No files matched your search

@@ -7,6 +7,12 @@
xmlns:c="clr-namespace:mbts.ui.controls"
xmlns:cv="clr-namespace:mbts.ui.converters"
>
<UserControl.Resources>
<cv:ValueMap x:Key="IsEnabledForegroundConverter" Default="{x:Static Brushes.Black}">
<cv:KeyValue Key="{u:False}" Value="{u:BTSBrush UI.input_disabled_text}" />
</cv:ValueMap>
</UserControl.Resources>
<Grid x:Name="_grid">
<c:ColorPickerPopup
x:Name="_color_picker_popup"
@@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="clr-namespace:mbts.ui"
xmlns:c="clr-namespace:mbts.ui.controls"
xmlns:cv="clr-namespace:mbts.ui.converters"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
>
<ResourceDictionary.MergedDictionaries>
@@ -16,6 +17,11 @@
<sys:Double x:Key="HorizontalPush">3.0</sys:Double>
<sys:Double x:Key="HorizontalGap">8.0</sys:Double>
<sys:Double x:Key="VerticalPush">4.0</sys:Double>
<cv:ValueMap x:Key="IsEnabledForegroundConverter" Default="{x:Static Brushes.Black}">
<cv:KeyValue Key="{u:False}" Value="{u:BTSBrush UI.input_disabled_text}" />
</cv:ValueMap>
<u:KeyedTemplateSelector x:Key="CellAnimationItemTemplateSelector">
<u:TemplateSelectorKeyValue Key="{x:Static c:CellAnimationTemplateKeys.FlashBackground}">
<DataTemplate>
@@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="clr-namespace:mbts.ui"
xmlns:c="clr-namespace:mbts.ui.controls"
xmlns:cv="clr-namespace:mbts.ui.converters"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
>
<ResourceDictionary.MergedDictionaries>
@@ -16,6 +17,11 @@
<sys:Double x:Key="HorizontalPush">3.0</sys:Double>
<sys:Double x:Key="HorizontalGap">8.0</sys:Double>
<sys:Double x:Key="VerticalPush">4.0</sys:Double>
<cv:ValueMap x:Key="IsEnabledForegroundConverter" Default="{x:Static Brushes.Black}">
<cv:KeyValue Key="{u:False}" Value="{u:BTSBrush UI.input_disabled_text}" />
</cv:ValueMap>
<u:KeyedTemplateSelector x:Key="RowAnimationItemTemplateSelector">
<u:TemplateSelectorKeyValue Key="{x:Static c:RowAnimationTemplateKeys.FlashBackground}">
<DataTemplate>
@@ -68,9 +68,6 @@
<cv:ValueMap x:Key="IsEnabledOpacityConverter" Default="{u:Double 1}">
<cv:KeyValue Key="{u:False}" Value="{u:Double 0.56}" />
</cv:ValueMap>
<cv:ValueMap x:Key="IsEnabledForegroundConverter" Default="{x:Static Brushes.Black}">
<cv:KeyValue Key="{u:False}" Value="{u:BTSBrush UI.input_disabled_text}" />
</cv:ValueMap>
<cv:ValueMap x:Key="IsNullConverter" Default="{u:False}">
<cv:KeyValue Key="{x:Null}" Value="{u:True}"/>
</cv:ValueMap>
@@ -25,6 +25,9 @@
<cv:ValueMap x:Key="ModeToDurationEnabledConverter" Default="{u:False}">
<cv:KeyValue Key="{u:Enum Flash, Type={u:Nested sp:ToastNotificationSettings.Mode}}" Value="{u:True}"/>
</cv:ValueMap>
<cv:ValueMap x:Key="IsEnabledForegroundConverter" Default="{x:Static Brushes.Black}">
<cv:KeyValue Key="{u:False}" Value="{u:BTSBrush UI.input_disabled_text}" />
</cv:ValueMap>
</ResourceDictionary>
</Window.Resources>
<Grid DataContext="{Binding Controller, RelativeSource={RelativeSource AncestorType=usp:NotificationSettingsView}}">