Skip to content

Commit

Permalink
Fixes #325 by checking access to the application main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Jun 11, 2016
1 parent b96a9ea commit 7785664
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [#305](../../issues/305) - Combobox items will be drawn above each other on scroll down
- [#311](../../issues/311) - State loading too verbose
- [#315](../../issues/315) - Menu button gets blurry
- [#325](../../issues/325) - Running RibbonWindow not on the main thread.

- ### Enhancements
- [#279](../../issues/279) - Localization of ColorGallery
Expand Down
2 changes: 1 addition & 1 deletion Fluent.Ribbon/Controls/RibbonTabItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ public void OnKeyTipPressed()
this.IsSelected = true;

// This way keytips for delay loaded elements work correctly. Partially fixes #244.
Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new Action(delegate { }));
this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new Action(delegate { }));
}

/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion Fluent.Ribbon/Converters/IconConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ object IValueConverter.Convert(object value, Type targetType, object parameter,
if (value == null)
{
if (Application.Current != null
&& Application.Current.MainWindow != null)
&& Application.Current.CheckAccess()
&& Application.Current.MainWindow != null
&& Application.Current.MainWindow.CheckAccess())
{
try
{
Expand Down
11 changes: 7 additions & 4 deletions Fluent.Ribbon/Converters/ObjectToImageConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ private static Image CreateImage(string imagePath, double desiredSize)
&& imagePath.EndsWith(".ico"))
{
return new Image
{
Source = ExtractImageFromIcoFile(imagePath, desiredSize)
};
{
Source = ExtractImageFromIcoFile(imagePath, desiredSize)
};
}

return new Image
Expand Down Expand Up @@ -160,7 +160,10 @@ private static ImageSource ExtractImage(BitmapDecoder decoder, double desiredSiz
{
var dpiFactor = 1.0;

if (Application.Current.MainWindow != null)
if (Application.Current != null
&& Application.Current.CheckAccess()
&& Application.Current.MainWindow != null
&& Application.Current.MainWindow.CheckAccess())
{
// dpi.M11 = dpiX, dpi.M22 = dpiY
var presentationSource = PresentationSource.FromVisual(Application.Current.MainWindow);
Expand Down

0 comments on commit 7785664

Please sign in to comment.