Fixed fonts disposing

This commit is contained in:
flabbet 2025-02-13 10:27:33 +00:00
parent c33f8c1c43
commit 5c9cfde7d5
11 changed files with 131 additions and 84 deletions

View File

@ -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
.env-dev/run-rider.nix Normal file
View File

@ -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

View File

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

1
.gitignore vendored
View File

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

View File

@ -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;
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;

View File

@ -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); internal record struct MethodInfo(string Name, List<TypeWithName> Arguments, NamespacedType ContainingClass);
} }

View File

@ -1,56 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<IncludeBuildOutput>false</IncludeBuildOutput> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings> <EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<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>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <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>
<ItemGroup> <ItemGroup>
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" /> <None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup> </ItemGroup>

View File

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

View File

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

View File

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

View File

@ -83,31 +83,31 @@
</ItemGroup> </ItemGroup>
<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" Version="$(AvaloniaVersion)"/>
<PackageReference Include="Avalonia.Headless" Version="$(AvaloniaVersion)"/> <PackageReference Include="Avalonia.Headless" Version="$(AvaloniaVersion)"/>
<PackageReference Include="Avalonia.Labs.Lottie" Version="11.2.0"/> <PackageReference Include="Avalonia.Labs.Lottie" Version="11.2.0"/>
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)"/> <PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)"/>
<PackageReference Include="Avalonia.Skia" 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.--> <!--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 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="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="DiscordRichPresence" Version="1.2.1.24"/>
<PackageReference Include="Hardware.Info" Version="101.0.0" /> <PackageReference Include="Hardware.Info" Version="101.0.0"/>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.11.0" /> <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.11.0"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/> <PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageReference Include="PixiEditor.ColorPicker.AvaloniaUI" Version="1.0.6"/> <PackageReference Include="PixiEditor.ColorPicker.AvaloniaUI" Version="1.0.6"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Drawie\src\Drawie.Interop.Avalonia\Drawie.Interop.Avalonia.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="..\Drawie\src\Drawie.Interop.Avalonia.Core\Drawie.Interop.Avalonia.Core.csproj"/>
<ProjectReference Include="..\PixiDocks\src\PixiDocks.Avalonia\PixiDocks.Avalonia.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.Skia\PixiParser.Skia.csproj"/>
<ProjectReference Include="..\PixiParser\src\PixiParser\PixiParser.csproj"/> <ProjectReference Include="..\PixiParser\src\PixiParser\PixiParser.csproj"/>
<ProjectReference Include="..\ChunkyImageLib\ChunkyImageLib.csproj"/> <ProjectReference Include="..\ChunkyImageLib\ChunkyImageLib.csproj"/>
@ -146,7 +146,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Extensions\" /> <Folder Include="Extensions\"/>
</ItemGroup> </ItemGroup>
</Project> </Project>