Skip to content

Commit 7d6fceb

Browse files
authored
Merge pull request #3467 from Flow-Launcher/warning_fix_tweak
Fix Dialog Owner & Improve Window Exiting & Improve WindowsThumbnailProvider & Fix Warnings
2 parents 309a710 + 4768290 commit 7d6fceb

21 files changed

+68
-124
lines changed

Diff for: Flow.Launcher.Infrastructure/Image/ImageLoader.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ private static async ValueTask<ImageResult> LoadInternalAsync(string path, bool
171171
}
172172
catch (System.Exception e2)
173173
{
174-
Log.Exception(ClassName, $"|ImageLoader.Load|Failed to get thumbnail for {path} on first try", e);
175-
Log.Exception(ClassName, $"|ImageLoader.Load|Failed to get thumbnail for {path} on second try", e2);
174+
Log.Exception(ClassName, $"Failed to get thumbnail for {path} on first try", e);
175+
Log.Exception(ClassName, $"Failed to get thumbnail for {path} on second try", e2);
176176

177177
ImageSource image = ImageCache[Constant.MissingImgIcon, false];
178178
ImageCache[path, false] = image;

Diff for: Flow.Launcher.Infrastructure/Image/ThumbnailReader.cs

+12-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Flow.Launcher.Infrastructure.Image
1313
{
1414
/// <summary>
15-
/// Subclass of <see cref="Windows.Win32.UI.Shell.SIIGBF"/>
15+
/// Subclass of <see cref="SIIGBF"/>
1616
/// </summary>
1717
[Flags]
1818
public enum ThumbnailOptions
@@ -31,7 +31,9 @@ public class WindowsThumbnailProvider
3131

3232
private static readonly Guid GUID_IShellItem = typeof(IShellItem).GUID;
3333

34-
private static readonly HRESULT S_ExtractionFailed = (HRESULT)0x8004B200;
34+
private static readonly HRESULT S_EXTRACTIONFAILED = (HRESULT)0x8004B200;
35+
36+
private static readonly HRESULT S_PATHNOTFOUND = (HRESULT)0x8004B205;
3537

3638
public static BitmapSource GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
3739
{
@@ -79,16 +81,22 @@ private static unsafe HBITMAP GetHBitmap(string fileName, int width, int height,
7981
{
8082
imageFactory.GetImage(size, (SIIGBF)options, &hBitmap);
8183
}
82-
catch (COMException ex) when (ex.HResult == S_ExtractionFailed && options == ThumbnailOptions.ThumbnailOnly)
84+
catch (COMException ex) when (options == ThumbnailOptions.ThumbnailOnly &&
85+
(ex.HResult == S_PATHNOTFOUND || ex.HResult == S_EXTRACTIONFAILED))
8386
{
84-
// Fallback to IconOnly if ThumbnailOnly fails
87+
// Fallback to IconOnly if extraction fails or files cannot be found
8588
imageFactory.GetImage(size, (SIIGBF)ThumbnailOptions.IconOnly, &hBitmap);
8689
}
8790
catch (FileNotFoundException) when (options == ThumbnailOptions.ThumbnailOnly)
8891
{
8992
// Fallback to IconOnly if files cannot be found
9093
imageFactory.GetImage(size, (SIIGBF)ThumbnailOptions.IconOnly, &hBitmap);
9194
}
95+
catch (System.Exception ex)
96+
{
97+
// Handle other exceptions
98+
throw new InvalidOperationException("Failed to get thumbnail", ex);
99+
}
92100
}
93101
finally
94102
{

Diff for: Flow.Launcher/Msg.xaml.cs

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ private void fadeOutStoryboard_Completed(object sender, EventArgs e)
5959
Close();
6060
}
6161

62+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "VSTHRD100:Avoid async void methods", Justification = "<Pending>")]
6263
public async void Show(string title, string subTitle, string iconPath)
6364
{
6465
tbTitle.Text = title;

Diff for: Flow.Launcher/ReportWindow.xaml.cs

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ namespace Flow.Launcher
1515
{
1616
internal partial class ReportWindow
1717
{
18-
private static readonly string ClassName = nameof(ReportWindow);
19-
2018
public ReportWindow(Exception exception)
2119
{
2220
InitializeComponent();

Diff for: Flow.Launcher/SettingPages/ViewModels/SettingsPanePluginsViewModel.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ public SettingsPanePluginsViewModel(Settings settings)
111111
.ToList();
112112

113113
[RelayCommand]
114-
private async Task OpenHelperAsync()
114+
private async Task OpenHelperAsync(Button button)
115115
{
116116
var helpDialog = new ContentDialog()
117117
{
118-
Owner = Application.Current.MainWindow,
118+
Owner = Window.GetWindow(button),
119119
Content = new StackPanel
120120
{
121121
Children =

Diff for: Flow.Launcher/SettingPages/Views/SettingsPanePlugins.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
Height="34"
5858
Margin="0 0 20 0"
5959
Command="{Binding OpenHelperCommand}"
60+
CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
6061
Content="&#xe9ce;"
6162
FontFamily="{DynamicResource SymbolThemeFontFamily}"
6263
FontSize="14" />

Diff for: Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using System.Windows.Navigation;
1+
using System.Windows.Navigation;
22
using CommunityToolkit.Mvvm.DependencyInjection;
33
using Flow.Launcher.SettingPages.ViewModels;
4-
using Page = ModernWpf.Controls.Page;
54
using Flow.Launcher.Infrastructure.UserSettings;
5+
using Page = ModernWpf.Controls.Page;
66

77
namespace Flow.Launcher.SettingPages.Views;
88

Diff for: Flow.Launcher/ViewModel/RelayCommand.cs

-29
This file was deleted.

Diff for: Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
</ItemGroup>
4646

4747
<ItemGroup>
48+
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
4849
<!-- Do not upgrade System.Data.OleDb since we are .Net7.0 -->
4950
<PackageReference Include="System.Data.OleDb" Version="8.0.1" />
5051
<PackageReference Include="System.Linq.Async" Version="6.0.1" />

Diff for: Plugins/Flow.Launcher.Plugin.Explorer/Helper/ShellContextMenu.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Text;
33
using System.Runtime.InteropServices;
44
using System.Drawing;
@@ -341,7 +341,7 @@ protected IntPtr[] GetPIDLs(DirectoryInfo[] arrFI)
341341
return null;
342342
}
343343

344-
IShellFolder oParentFolder = GetParentFolder(arrFI[0].Parent.FullName);
344+
IShellFolder oParentFolder = GetParentFolder(arrFI[0].Parent!.FullName);
345345
if (null == oParentFolder)
346346
{
347347
return null;
@@ -1535,7 +1535,7 @@ public void Install()
15351535
m_hookType,
15361536
m_filterFunc,
15371537
IntPtr.Zero,
1538-
(int)AppDomain.GetCurrentThreadId());
1538+
Environment.CurrentManagedThreadId);
15391539
}
15401540
// ************************************************************************
15411541

Diff for: Plugins/Flow.Launcher.Plugin.Explorer/Helper/SortOptionTranslationHelper.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static string GetTranslatedName(this SortOption sortOption)
1616
ArgumentNullException.ThrowIfNull(API);
1717

1818
var enumName = Enum.GetName(sortOption);
19-
var splited = enumName.Split('_');
19+
var splited = enumName!.Split('_');
2020
var name = string.Join('_', splited[..^1]);
2121
var direction = splited[^1];
2222

Diff for: Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private static void LoadEnvironmentStringPaths()
4747

4848
foreach (DictionaryEntry special in Environment.GetEnvironmentVariables())
4949
{
50-
var path = special.Value.ToString();
50+
var path = special.Value!.ToString();
5151
// we add a trailing slash to the path to make sure drive paths become valid absolute paths.
5252
// for example, if %systemdrive% is C: we turn it to C:\
5353
path = path.EnsureTrailingSlash();
@@ -61,7 +61,7 @@ private static void LoadEnvironmentStringPaths()
6161
{
6262
// Variables are returned with a mixture of all upper/lower case.
6363
// Call ToUpper() to make the results look consistent
64-
_envStringPaths.Add(special.Key.ToString().ToUpper(), path);
64+
_envStringPaths.Add(special.Key.ToString()!.ToUpper(), path);
6565
}
6666
}
6767
}

Diff for: Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/ActionKeywordModel.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
using System.ComponentModel;
22
using System.Runtime.CompilerServices;
33

4+
#nullable enable
5+
46
namespace Flow.Launcher.Plugin.Explorer.Views
57
{
68
public class ActionKeywordModel : INotifyPropertyChanged
79
{
8-
private static Settings _settings;
10+
private static Settings _settings = null!;
911

10-
public event PropertyChangedEventHandler PropertyChanged;
12+
public event PropertyChangedEventHandler? PropertyChanged;
1113

1214
public static void Init(Settings settings)
1315
{
@@ -54,4 +56,4 @@ public bool Enabled
5456
}
5557
}
5658
}
57-
}
59+
}

Diff for: Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/RelayCommand.cs

-27
This file was deleted.

0 commit comments

Comments
 (0)