Browse Source

Merge pull request #949 from PixiEditor/fixes/23.05.2025

Fixed critical color comparision bug
Krzysztof Krysiński 2 months ago
parent
commit
d7b4ceec56
1 changed files with 12 additions and 6 deletions
  1. 12 6
      src/PixiEditor.Extensions.CommonApi/Palettes/PaletteColor.Impl.cs

+ 12 - 6
src/PixiEditor.Extensions.CommonApi/Palettes/PaletteColor.Impl.cs

@@ -17,33 +17,33 @@ public partial class PaletteColor : IEquatable<PaletteColor>
         get => (byte)GValue;
         get => (byte)GValue;
         set => GValue = value;
         set => GValue = value;
     }
     }
-    
+
     public byte B
     public byte B
     {
     {
         get => (byte)BValue;
         get => (byte)BValue;
         set => BValue = value;
         set => BValue = value;
     }
     }
-    
+
     public string Hex => $"#{R:X2}{G:X2}{B:X2}";
     public string Hex => $"#{R:X2}{G:X2}{B:X2}";
-    
+
     public PaletteColor(byte r, byte g, byte b)
     public PaletteColor(byte r, byte g, byte b)
     {
     {
         RValue = r;
         RValue = r;
         GValue = g;
         GValue = g;
         BValue = b;
         BValue = b;
     }
     }
-    
+
     public PaletteColor(uint r, uint g, uint b)
     public PaletteColor(uint r, uint g, uint b)
     {
     {
         RValue = (byte)r;
         RValue = (byte)r;
         GValue = (byte)g;
         GValue = (byte)g;
         BValue = (byte)b;
         BValue = (byte)b;
     }
     }
-    
+
     public PaletteColor()
     public PaletteColor()
     {
     {
     }
     }
-    
+
     public override string ToString()
     public override string ToString()
     {
     {
         return Hex;
         return Hex;
@@ -51,6 +51,12 @@ public partial class PaletteColor : IEquatable<PaletteColor>
 
 
     public static bool operator ==(PaletteColor left, PaletteColor right)
     public static bool operator ==(PaletteColor left, PaletteColor right)
     {
     {
+        if (left is null && right is null)
+            return true;
+
+        if (left is null || right is null)
+            return false;
+
         return left.R == right.R && left.G == right.G && left.B == right.B;
         return left.R == right.R && left.G == right.G && left.B == right.B;
     }
     }