Skip to content

Commit

Permalink
Merge branch 'hotfix/2.4.5' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Apr 20, 2021
2 parents 29a0ac4 + 135c2d8 commit 4025dca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
18 changes: 8 additions & 10 deletions src/MahApps.Metro/Behaviors/WindowsSettingBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ private void AssociatedObject_SourceInitialized(object sender, EventArgs e)
window.Closing += this.AssociatedObject_Closing;
window.Closed += this.AssociatedObject_Closed;

// This operation must be thread safe
window.BeginInvoke(() =>
// This operation must be thread safe. It is possible, that the window is running in a different Thread.
Application.Current?.BeginInvoke(app =>
{
var application = Application.Current;
if (application != null)
if (app != null)
{
application.SessionEnding += this.CurrentApplicationSessionEnding;
app.SessionEnding += this.CurrentApplicationSessionEnding;
}
});
});
}

private void AssociatedObject_Closing(object sender, System.ComponentModel.CancelEventArgs e)
Expand Down Expand Up @@ -100,12 +99,11 @@ private void CleanUp(string fromWhere)
window.SourceInitialized -= this.AssociatedObject_SourceInitialized;

// This operation must be thread safe
window.BeginInvoke(() =>
Application.Current?.BeginInvoke(app =>
{
var application = Application.Current;
if (application != null)
if (app != null)
{
application.SessionEnding -= this.CurrentApplicationSessionEnding;
app.SessionEnding -= this.CurrentApplicationSessionEnding;
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/MahApps.Metro/Controls/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void BeginInvoke([NotNull] this DispatcherObject dispatcherObject,
throw new ArgumentNullException(nameof(invokeAction));
}

dispatcherObject.Dispatcher.BeginInvoke(priority, invokeAction);
dispatcherObject.Dispatcher?.BeginInvoke(priority, invokeAction);
}

public static void BeginInvoke<T>([NotNull] this T dispatcherObject, [NotNull] Action<T> invokeAction, DispatcherPriority priority = DispatcherPriority.Background)
Expand Down
5 changes: 2 additions & 3 deletions src/MahApps.Metro/Themes/DateTimePicker.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@

<Trigger Property="IsClockVisible" Value="False">
<Setter TargetName="PART_Clock" Property="Visibility" Value="Collapsed" />
<Setter TargetName="PART_ClockPartSelectorsHolder" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsDatePickerVisible" Value="True">
<Setter TargetName="PART_Calendar" Property="Visibility" Value="Visible" />
Expand Down Expand Up @@ -474,10 +473,10 @@
<Condition Binding="{Binding Path=(mah:TextBoxHelper.HasText), RelativeSource={RelativeSource Self}}" Value="True" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{DynamicResource MahApps.Storyboard.ShowFloatingMessage}" />
<BeginStoryboard Storyboard="{StaticResource MahApps.Storyboard.ShowFloatingMessage}" />
</MultiDataTrigger.EnterActions>
<MultiDataTrigger.ExitActions>
<BeginStoryboard Storyboard="{DynamicResource MahApps.Storyboard.HideFloatingMessage}" />
<BeginStoryboard Storyboard="{StaticResource MahApps.Storyboard.HideFloatingMessage}" />
</MultiDataTrigger.ExitActions>
</MultiDataTrigger>

Expand Down

0 comments on commit 4025dca

Please sign in to comment.