- fix: memory leak part 1
This commit is contained in:
@@ -28,6 +28,7 @@ public sealed partial class FavoriteServerListProvider : IServerListProvider, IS
|
||||
|
||||
public bool IsLoaded { get; private set; }
|
||||
public Action? OnLoaded { get; set; }
|
||||
public Action? OnDisposed { get; set; }
|
||||
public Action? Dirty { get; set; }
|
||||
public IEnumerable<IListEntryModelView> GetServers()
|
||||
{
|
||||
@@ -108,9 +109,14 @@ public sealed partial class FavoriteServerListProvider : IServerListProvider, IS
|
||||
}
|
||||
|
||||
private void InitialiseInDesignMode(){}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
OnDisposed?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public class AddFavoriteButton: Border, IListEntryModelView{
|
||||
public sealed class AddFavoriteButton: Border, IListEntryModelView{
|
||||
|
||||
private Button _addFavoriteButton = new Button();
|
||||
public AddFavoriteButton(IServiceProvider serviceProvider)
|
||||
@@ -128,4 +134,9 @@ public class AddFavoriteButton: Border, IListEntryModelView{
|
||||
Child = _addFavoriteButton;
|
||||
}
|
||||
public bool IsFavorite { get; set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Nebula.Launcher.ViewModels;
|
||||
using Nebula.Launcher.ViewModels.Pages;
|
||||
using Nebula.Shared;
|
||||
using Nebula.Shared.Models;
|
||||
@@ -22,6 +20,7 @@ public sealed partial class HubServerListProvider : IServerListProvider
|
||||
|
||||
public bool IsLoaded { get; private set; }
|
||||
public Action? OnLoaded { get; set; }
|
||||
public Action? OnDisposed { get; set; }
|
||||
|
||||
private CancellationTokenSource? _cts;
|
||||
private readonly List<IListEntryModelView> _servers = [];
|
||||
@@ -83,4 +82,10 @@ public sealed partial class HubServerListProvider : IServerListProvider
|
||||
|
||||
private void Initialise(){}
|
||||
private void InitialiseInDesignMode(){}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
OnDisposed?.Invoke();
|
||||
_cts?.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,11 @@ using Nebula.Launcher.ViewModels.Pages;
|
||||
|
||||
namespace Nebula.Launcher.ServerListProviders;
|
||||
|
||||
public interface IServerListProvider
|
||||
public interface IServerListProvider : IDisposable
|
||||
{
|
||||
public bool IsLoaded { get; }
|
||||
public Action? OnLoaded { get; set; }
|
||||
public Action? OnDisposed { get; set; }
|
||||
|
||||
public IEnumerable<IListEntryModelView> GetServers();
|
||||
public IEnumerable<Exception> GetErrors();
|
||||
|
||||
@@ -10,6 +10,8 @@ public sealed class TestServerList : IServerListProvider
|
||||
{
|
||||
public bool IsLoaded => true;
|
||||
public Action? OnLoaded { get; set; }
|
||||
public Action? OnDisposed { get; set; }
|
||||
|
||||
public IEnumerable<IListEntryModelView> GetServers()
|
||||
{
|
||||
return [new ServerEntryModelView(),new ServerEntryModelView()];
|
||||
@@ -24,4 +26,9 @@ public sealed class TestServerList : IServerListProvider
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
OnDisposed?.Invoke();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user