Przeglądaj źródła

Fixed fonts disposing

flabbet 5 miesięcy temu
rodzic
commit
5c9cfde7d5

+ 39 - 0
.env-dev/run-build-bin.nix

@@ -0,0 +1,39 @@
+{ pkgs ? import <nixpkgs> {} }:
+
+
+(pkgs.buildFHSEnv {
+  name = "pixieditor-env";
+  targetPkgs = pkgs: (with pkgs; [
+    dotnet-sdk
+    avalonia
+    fontconfig
+    alsa-lib
+    glew
+    udev
+    gnumake 
+    vulkan-headers
+    vulkan-loader
+    vulkan-validation-layers
+    vulkan-tools
+    vulkan-tools-lunarg
+    powershell
+  ]) ++ (with pkgs.xorg; [
+   libX11
+    libICE
+    libSM
+    libXi
+    libXcursor
+    libXext
+    libXrandr  ]);
+
+  multiPkgs = pkgs: (with pkgs; [
+   udev
+   alsa-lib
+  ]);
+
+  runScript = "nohup ./PixiEditor &";
+}).env
+
+
+
+

+ 35 - 0
.env-dev/run-rider.nix

@@ -0,0 +1,35 @@
+{ pkgs ? import <nixpkgs> {} }:
+
+
+(pkgs.buildFHSEnv {
+  name = "rider-env";
+  targetPkgs = pkgs: (with pkgs; [
+    dotnet-sdk
+    avalonia
+    fontconfig
+    alsa-lib
+    glew
+    udev
+    gnumake 
+    vulkan-headers
+    vulkan-loader
+    vulkan-validation-layers
+    vulkan-tools
+    vulkan-tools-lunarg
+    powershell
+  ]) ++ (with pkgs.xorg; [
+   libX11
+    libICE
+    libSM
+    libXi
+    libXcursor
+    libXext
+    libXrandr  ]);
+
+  multiPkgs = pkgs: (with pkgs; [
+   udev
+   alsa-lib
+  ]);
+
+  runScript = "nohup rider &";
+}).env

+ 11 - 12
.env-dev/shell.nix

@@ -1,10 +1,14 @@
-{ pkgs ? import <nixpkgs> {} }:
+{ pkgs ? import <nixpkgs> { } }:
 
+with pkgs;
+let
 
-(pkgs.buildFHSEnv {
-  name = "rider-env";
-  targetPkgs = pkgs: (with pkgs; [
-    dotnetCorePackages.dotnet_8.sdk
+dotnet = dotnet-sdk; 
+
+in mkShell {
+  name = "avalonia-env";
+  packages = (with pkgs; [
+    dotnet
     avalonia
     fontconfig
     alsa-lib
@@ -26,10 +30,5 @@
     libXext
     libXrandr  ]);
 
-  multiPkgs = pkgs: (with pkgs; [
-   udev
-   alsa-lib
-  ]);
-
-  runScript = "nohup rider &";
-}).env
+    DOTNET_ROOT = "${dotnet}";
+}

+ 1 - 0
.gitignore

@@ -340,3 +340,4 @@ GitIgnore
 
 Cache/
 .DS_Store
+nohup.out

+ 4 - 1
src/PixiEditor.ChangeableDocument.Gen/Helpers.cs

@@ -1,4 +1,7 @@
-using System.Text;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
 using Microsoft.CodeAnalysis;
 using Microsoft.CodeAnalysis.CSharp.Syntax;
 

+ 3 - 1
src/PixiEditor.ChangeableDocument.Gen/MethodInfo.cs

@@ -1,4 +1,6 @@
-namespace PixiEditor.ChangeableDocument.Gen
+using System.Collections.Generic;
+
+namespace PixiEditor.ChangeableDocument.Gen
 {
     internal record struct MethodInfo(string Name, List<TypeWithName> Arguments, NamespacedType ContainingClass);
 }

+ 6 - 46
src/PixiEditor.ChangeableDocument.Gen/PixiEditor.ChangeableDocument.Gen.csproj

@@ -1,57 +1,17 @@
 <Project Sdk="Microsoft.NET.Sdk">
-
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <IncludeBuildOutput>false</IncludeBuildOutput>
+    <LangVersion>latest</LangVersion>
     <Nullable>enable</Nullable>
-    <ImplicitUsings>true</ImplicitUsings>
-    <LangVersion>Latest</LangVersion>
-    <Configurations>Debug;Release;Steam;DevRelease</Configurations>
-    <Platforms>AnyCPU</Platforms>
-  </PropertyGroup>
-
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Steam|AnyCPU'">
-    <Optimize>True</Optimize>
-  </PropertyGroup>
-
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Steam|x64'">
-    <Optimize>True</Optimize>
-    <PlatformTarget>AnyCPU</PlatformTarget>
-  </PropertyGroup>
-
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Steam|x86'">
-    <Optimize>True</Optimize>
-    <PlatformTarget>AnyCPU</PlatformTarget>
-  </PropertyGroup>
-
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-  </PropertyGroup>
-
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-  </PropertyGroup>
-
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DevRelease|x64' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-  </PropertyGroup>
-
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DevRelease|x86' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-  </PropertyGroup>
-
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-  </PropertyGroup>
-
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
+    <EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
+    <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" PrivateAssets="all" />
+    <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" PrivateAssets="all" />
   </ItemGroup>
+
   <ItemGroup>
     <None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
   </ItemGroup>
-</Project>
+</Project>

+ 3 - 1
src/PixiEditor.ChangeableDocument.Gen/UpdateableChangeActionGenerator.cs

@@ -1,4 +1,6 @@
-using Microsoft.CodeAnalysis;
+using System.Linq;
+using System.Threading;
+using Microsoft.CodeAnalysis;
 using Microsoft.CodeAnalysis.CSharp.Syntax;
 using Microsoft.CodeAnalysis.Text;
 

+ 1 - 1
src/PixiEditor.Gen/PixiEditor.Gen.csproj

@@ -4,7 +4,7 @@
     <TargetFramework>netstandard2.0</TargetFramework>
     <IncludeBuildOutput>true</IncludeBuildOutput>
     <Nullable>enable</Nullable>
-    <ImplicitUsings>enable</ImplicitUsings>
+    <ImplicitUsings>true</ImplicitUsings>
     <LangVersion>latest</LangVersion>
     <RootNamespace>PixiEditorGen</RootNamespace>
   </PropertyGroup>

+ 13 - 7
src/PixiEditor/Models/DocumentModels/UpdateableChangeExecutors/VectorTextToolExecutor.cs

@@ -31,6 +31,8 @@ internal class VectorTextToolExecutor : UpdateableChangeExecutor, ITextOverlayEv
     private Font? cachedFont;
     private bool isListeningForValidLayer;
     private VectorPath? onPath;
+    
+    private List<Font> fontsToDispose = new();
 
     public override bool BlocksOtherActions => false;
 
@@ -134,6 +136,16 @@ internal class VectorTextToolExecutor : UpdateableChangeExecutor, ITextOverlayEv
     {
         internals.ActionAccumulator.AddFinishedActions(new EndSetShapeGeometry_Action());
         document.TextOverlayHandler.Hide();
+        
+        foreach (var font in fontsToDispose)
+        {
+            if (font != null && !font.IsDisposed)
+            {
+                font.Dispose();
+            }
+        }
+        
+        fontsToDispose.Clear();
     }
 
     public void OnTextChanged(string text)
@@ -156,12 +168,7 @@ internal class VectorTextToolExecutor : UpdateableChangeExecutor, ITextOverlayEv
 
         if (name == nameof(ITextToolbar.FontFamily))
         {
-            Font toDispose = cachedFont;
-            Dispatcher.UIThread.Post(() =>
-            {
-                toDispose?.Dispose();
-            });
-
+            fontsToDispose.Add(cachedFont);
             cachedFont = toolbar.ConstructFont();
             document.TextOverlayHandler.Font = cachedFont;
         }
@@ -257,7 +264,6 @@ internal class VectorTextToolExecutor : UpdateableChangeExecutor, ITextOverlayEv
             AntiAlias = toolbar.AntiAliasing,
             Path = onPath,
             // TODO: MaxWidth = toolbar.MaxWidth
-            // TODO: Path
         };
     }
 

+ 15 - 15
src/PixiEditor/PixiEditor.csproj

@@ -51,7 +51,7 @@
   <ItemGroup Condition="'$(Configuration)' == 'DevSteam'">
     <ProjectReference Include="..\PixiEditor.Platform.Steam\PixiEditor.Platform.Steam.csproj"/>
   </ItemGroup>
-  
+
   <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
     <ProjectReference Include="..\PixiEditor.Platform.Standalone\PixiEditor.Platform.Standalone.csproj"/>
   </ItemGroup>
@@ -59,15 +59,15 @@
   <ItemGroup Condition=" '$(Configuration)' == 'Release' ">
     <ProjectReference Include="..\PixiEditor.Platform.Standalone\PixiEditor.Platform.Standalone.csproj"/>
   </ItemGroup>
-  
+
   <ItemGroup Condition=" '$(Configuration)' == 'DevRelease' ">
     <ProjectReference Include="..\PixiEditor.Platform.Standalone\PixiEditor.Platform.Standalone.csproj"/>
   </ItemGroup>
-  
+
   <ItemGroup Condition=" '$(Configuration)' == 'MSIX' ">
     <ProjectReference Include="..\PixiEditor.Platform.MSStore\PixiEditor.Platform.MSStore.csproj"/>
   </ItemGroup>
-  
+
   <ItemGroup Condition=" '$(Configuration)' == 'MSIX Debug' ">
     <ProjectReference Include="..\PixiEditor.Platform.MSStore\PixiEditor.Platform.MSStore.csproj"/>
   </ItemGroup>
@@ -83,31 +83,31 @@
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Include="AsyncImageLoader.Avalonia" Version="3.3.0" />
+    <PackageReference Include="AsyncImageLoader.Avalonia" Version="3.3.0"/>
     <PackageReference Include="Avalonia" Version="$(AvaloniaVersion)"/>
     <PackageReference Include="Avalonia.Headless" Version="$(AvaloniaVersion)"/>
     <PackageReference Include="Avalonia.Labs.Lottie" Version="11.2.0"/>
     <PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)"/>
     <PackageReference Include="Avalonia.Skia" Version="$(AvaloniaVersion)"/>
-    <PackageReference Include="Avalonia.Svg.Skia" Version="11.2.0" />
+    <PackageReference Include="Avalonia.Svg.Skia" Version="11.2.0"/>
     <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
     <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)"/>
-    <PackageReference Include="ByteSize" Version="2.1.2" />
+    <PackageReference Include="ByteSize" Version="2.1.2"/>
     <PackageReference Include="CLSEncoderDecoder" Version="1.0.0"/>
-    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
+    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2"/>
     <PackageReference Include="DiscordRichPresence" Version="1.2.1.24"/>
-    <PackageReference Include="Hardware.Info" Version="101.0.0" />
-    <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.11.0" />
-    <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
+    <PackageReference Include="Hardware.Info" Version="101.0.0"/>
+    <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.11.0"/>
+    <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0"/>
     <PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
     <PackageReference Include="PixiEditor.ColorPicker.AvaloniaUI" Version="1.0.6"/>
   </ItemGroup>
 
   <ItemGroup>
-    <ProjectReference Include="..\Drawie\src\Drawie.Interop.Avalonia\Drawie.Interop.Avalonia.csproj" />
-    <ProjectReference Include="..\Drawie\src\Drawie.Interop.Avalonia.Core\Drawie.Interop.Avalonia.Core.csproj" />
+    <ProjectReference Include="..\Drawie\src\Drawie.Interop.Avalonia\Drawie.Interop.Avalonia.csproj"/>
+    <ProjectReference Include="..\Drawie\src\Drawie.Interop.Avalonia.Core\Drawie.Interop.Avalonia.Core.csproj"/>
     <ProjectReference Include="..\PixiDocks\src\PixiDocks.Avalonia\PixiDocks.Avalonia.csproj"/>
-    <ProjectReference Include="..\PixiEditor.SVG\PixiEditor.SVG.csproj" />
+    <ProjectReference Include="..\PixiEditor.SVG\PixiEditor.SVG.csproj"/>
     <ProjectReference Include="..\PixiParser\src\PixiParser.Skia\PixiParser.Skia.csproj"/>
     <ProjectReference Include="..\PixiParser\src\PixiParser\PixiParser.csproj"/>
     <ProjectReference Include="..\ChunkyImageLib\ChunkyImageLib.csproj"/>
@@ -146,7 +146,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <Folder Include="Extensions\" />
+    <Folder Include="Extensions\"/>
   </ItemGroup>
 
 </Project>