Browse Source

2024.3.0-rc2

Marcin Ziąbek 1 year ago
parent
commit
27332ddf15

+ 14 - 5
Source/QuestPDF/Infrastructure/TextStyleManager.cs

@@ -87,13 +87,22 @@ namespace QuestPDF.Infrastructure
                 value = new FontFamiliesValue((string[]?)value);
                 value = new FontFamiliesValue((string[]?)value);
             
             
             var cacheKey = (origin.Id, property, value);
             var cacheKey = (origin.Id, property, value);
-            return TextStyleMutateCache.GetOrAdd(cacheKey, x => MutateStyle(TextStyles[x.originId], x.property, x.value, overrideValue: true));
+            
+            return TextStyleMutateCache.GetOrAdd(cacheKey, x =>
+            {
+                var newValue = x.value;
+                
+                if (x.value is FontFamiliesValue fontFamiliesValue)
+                    newValue = fontFamiliesValue.Items;
+   
+                return MutateStyle(TextStyles[x.originId], x.property, newValue, overrideValue: true);
+            });
         }
         }
 
 
         private static TextStyle MutateStyle(this TextStyle origin, TextStyleProperty targetProperty, object? newValue, bool overrideValue)
         private static TextStyle MutateStyle(this TextStyle origin, TextStyleProperty targetProperty, object? newValue, bool overrideValue)
         {
         {
             if (targetProperty == TextStyleProperty.FontFamilies)
             if (targetProperty == TextStyleProperty.FontFamilies)
-                return MutateFontFamily(origin, (FontFamiliesValue?)newValue, overrideValue);
+                return MutateFontFamily(origin, newValue as string[], overrideValue);
             
             
             lock (MutationLock)
             lock (MutationLock)
             {
             {
@@ -121,18 +130,18 @@ namespace QuestPDF.Infrastructure
             }
             }
         }
         }
         
         
-        private static TextStyle MutateFontFamily(this TextStyle origin, FontFamiliesValue? newValueContainer, bool overrideValue)
+        private static TextStyle MutateFontFamily(this TextStyle origin, string[]? newValue, bool overrideValue)
         {
         {
             lock (MutationLock)
             lock (MutationLock)
             {
             {
-                if (overrideValue && newValueContainer is null)
+                if (overrideValue && newValue is null)
                     return origin;
                     return origin;
                 
                 
                 var newIndex = TextStyles.Count;
                 var newIndex = TextStyles.Count;
                 var newTextStyle = origin with { Id = newIndex };
                 var newTextStyle = origin with { Id = newIndex };
                 newTextStyle.Id = newIndex;
                 newTextStyle.Id = newIndex;
                 
                 
-                var newValue = newValueContainer?.Items ?? Array.Empty<string>();
+                newValue ??= Array.Empty<string>();
                 var oldValue = origin.FontFamilies ?? Array.Empty<string>();
                 var oldValue = origin.FontFamilies ?? Array.Empty<string>();
                 
                 
                 if (origin.FontFamilies?.SequenceEqual(newValue) == true)
                 if (origin.FontFamilies?.SequenceEqual(newValue) == true)

+ 1 - 1
Source/QuestPDF/QuestPDF.csproj

@@ -3,7 +3,7 @@
         <Authors>MarcinZiabek</Authors>
         <Authors>MarcinZiabek</Authors>
         <Company>CodeFlint</Company>
         <Company>CodeFlint</Company>
         <PackageId>QuestPDF</PackageId>
         <PackageId>QuestPDF</PackageId>
-        <Version>2024.3.0-rc1</Version>
+        <Version>2024.3.0-rc2</Version>
         <PackageDescription>QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API. Easily generate PDF reports, invoices, exports, etc.</PackageDescription>
         <PackageDescription>QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API. Easily generate PDF reports, invoices, exports, etc.</PackageDescription>
         <PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/Resources/ReleaseNotes.txt"))</PackageReleaseNotes>
         <PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/Resources/ReleaseNotes.txt"))</PackageReleaseNotes>
         <LangVersion>10</LangVersion>
         <LangVersion>10</LangVersion>

+ 5 - 0
Source/QuestPDF/Resources/ReleaseNotes.txt

@@ -65,3 +65,8 @@ Version 2024.3.0-rc1
 - Fixed memory leaks in the native code,
 - Fixed memory leaks in the native code,
 - Fixed: the DocumentMetadata.CreationDate and DocumentMetadata.ModificationDate properties are not properly populated in generated PDF,
 - Fixed: the DocumentMetadata.CreationDate and DocumentMetadata.ModificationDate properties are not properly populated in generated PDF,
 - Fixed: when changing the TextStyle.FontFamilies property, the cache does not work correctly leading to higher memory usage.
 - Fixed: when changing the TextStyle.FontFamilies property, the cache does not work correctly leading to higher memory usage.
+
+
+
+Version 2024.3.0-rc2
+- Fixed critical issue: the library fails during PDF generation