瀏覽代碼

Merge branch 'master' into release

flabbet 1 年之前
父節點
當前提交
3ca16ab9c1

+ 20 - 1
src/PixiEditor/Models/DataProviders/LocalPalettesFetcher.cs

@@ -4,6 +4,7 @@ using PixiEditor.Extensions.Common.Localization;
 using PixiEditor.Extensions.Common.UserPreferences;
 using PixiEditor.Extensions.Palettes;
 using PixiEditor.Extensions.Palettes.Parsers;
+using PixiEditor.Helpers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders.Palettes;
 using PixiEditor.Models.IO;
@@ -150,7 +151,7 @@ internal class LocalPalettesFetcher : PaletteListDataSource
     {
         string[] files = DirectoryExtensions.GetFiles(
             Paths.PathToPalettesFolder,
-            string.Join("|", AvailableParsers.SelectMany(x => x.SupportedFileExtensions)),
+            string.Join("|", AvailableParsers.SelectMany(x => x.SupportedFileExtensions).Distinct()),
             SearchOption.TopDirectoryOnly);
         cachedPalettes = await ParseAll(files);
         CacheUpdated?.Invoke(RefreshType.All, null, null);
@@ -219,6 +220,24 @@ internal class LocalPalettesFetcher : PaletteListDataSource
             default:
                 throw new ArgumentOutOfRangeException(nameof(refreshType), refreshType, null);
         }
+
+        if (refreshType is RefreshType.Created or RefreshType.Updated && updated == null)
+        {
+            await RefreshCacheAll();
+            
+            // Using try-catch to generate stack trace
+            try
+            {
+                throw new NullReferenceException($"The '{nameof(updated)}' was null even though the refresh type was '{refreshType}'.");
+            }
+            catch (Exception e)
+            {
+                await CrashHelper.SendExceptionInfoToWebhookAsync(e);
+            }
+
+            return;
+        }
+        
         CacheUpdated?.Invoke(refreshType, updated, affectedFileName);
     }
 

+ 1 - 2
src/PixiEditor/Models/IO/PaletteParsers/JascPalFile/JascFileParser.cs

@@ -1,5 +1,4 @@
 using System.IO;
-using PixiEditor.DrawingApi.Core.ColorsImpl;
 using PixiEditor.Extensions.Palettes;
 using PixiEditor.Extensions.Palettes.Parsers;
 
@@ -10,7 +9,7 @@ namespace PixiEditor.Models.IO.PaletteParsers.JascPalFile;
 /// </summary>
 internal class JascFileParser : PaletteFileParser
 {
-    private static readonly string[] _supportedFileExtensions = new string[] { ".pal" };
+    private static readonly string[] _supportedFileExtensions = new string[] { ".pal", ".psppalette" };
     public override string[] SupportedFileExtensions => _supportedFileExtensions;
     public override string FileName => "Jasc Palette";
 

+ 2 - 2
src/PixiEditor/Properties/AssemblyInfo.cs

@@ -50,5 +50,5 @@ using System.Windows;
 // You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.2.4.0")]
-[assembly: AssemblyFileVersion("1.2.4.0")]
+[assembly: AssemblyVersion("1.2.5.0")]
+[assembly: AssemblyFileVersion("1.2.5.0")]

+ 2 - 2
src/PixiEditor/Views/Dialogs/PalettesBrowser.xaml

@@ -50,8 +50,8 @@
         <DockPanel Background="{StaticResource MainColor}" Grid.Row="1">
             <StackPanel HorizontalAlignment="Left" Margin="10" Orientation="Horizontal" VerticalAlignment="Center">
                 <Label ui:Translator.Key="SORT_BY" Style="{StaticResource BaseLabel}" VerticalAlignment="Center"/>
-                <ComboBox x:Name="sortingComboBox" VerticalAlignment="Center" SelectionChanged="SortingComboBox_SelectionChanged">
-                    <ComboBoxItem IsSelected="True" ui:Translator.Key="DEFAULT"/>
+                <ComboBox x:Name="sortingComboBox" SelectedIndex="0" VerticalAlignment="Center" SelectionChanged="SortingComboBox_SelectionChanged">
+                    <ComboBoxItem ui:Translator.Key="DEFAULT"/>
                     <ComboBoxItem ui:Translator.Key="ALPHABETICAL"/>
                     <ComboBoxItem ui:Translator.Key="COLOR_COUNT"/>
                 </ComboBox>

+ 10 - 2
src/PixiEditor/Views/Dialogs/PalettesBrowser.xaml.cs

@@ -310,8 +310,16 @@ internal partial class PalettesBrowser : Window, IPopupWindow
 
     private void HandleCachePaletteCreated(Palette updatedItem)
     {
-        SortedResults.Add(updatedItem);
-        PaletteList.Palettes.Add(updatedItem);
+        if (!SortedResults.Contains(updatedItem))
+        {
+            SortedResults.Add(updatedItem);
+        }
+
+        if(!PaletteList.Palettes.Contains(updatedItem))
+        {
+            PaletteList.Palettes.Add(updatedItem);
+        }
+
         Sort();
     }