From 34b74ecdcd46e933e278d6d396fb34c2815fedcc Mon Sep 17 00:00:00 2001 From: EugeneTes Date: Mon, 23 Mar 2026 10:30:30 +0100 Subject: [PATCH] path fix --- .../EmulationCameraImageSource.cs | 2 +- .../Hawkeye.VisionBuilder.Workflow.csproj | 1 - .../Detectors/BlisterDetector.cs | 2 +- .../CandyboxPlugin/Detectors/CandyDetector.cs | 2 +- .../Components/Layout/MainLayout.razor.cs | 3 +++ VisionBuilder.UI.Blazor.Uno/Program.cs | 2 +- .../VisionBuilder.UI.Blazor.Uno.csproj | 1 + .../Components/ErrorPreview.razor.cs | 3 +++ .../Components/PreviewWindow.razor.cs | 4 ++++ .../Components/SingleCameraControl.razor.cs | 3 +++ .../Components/Stats.razor.cs | 4 ++++ .../Dialogs/ImagePreviewDialog.razor | 19 +++++++++++++++---- .../WorkflowRecipeHelper.cs | 2 +- .../VisionBuilderRingbufferSettings.cs | 2 +- .../VisionBuilderStatisticsSettings.cs | 2 +- VisionBuilder.UI.Windows.Duo/Program.cs | 2 +- .../Emulation/EmulationCamera.cs | 2 +- 17 files changed, 42 insertions(+), 14 deletions(-) diff --git a/Hawkeye.VisionBuilder.UI.Sources.Emulation/EmulationCameraImageSource.cs b/Hawkeye.VisionBuilder.UI.Sources.Emulation/EmulationCameraImageSource.cs index 7497812..5a087f9 100644 --- a/Hawkeye.VisionBuilder.UI.Sources.Emulation/EmulationCameraImageSource.cs +++ b/Hawkeye.VisionBuilder.UI.Sources.Emulation/EmulationCameraImageSource.cs @@ -80,7 +80,7 @@ namespace Hawkeye.VisionBuilder.UI.Sources.Emulation try { _currentFolder = imagesFolder; - var path = Path.Combine(@"..\Data\Emulation", imagesFolder); + var path = Path.Combine("..", "Data", "Emulation", imagesFolder); _selectedFiles = Directory.GetFiles(path, "*.bmp") .Concat(Directory.GetFiles(path, "*.png")) .Concat(Directory.GetFiles(path, "*.jpg")) diff --git a/Hawkeye.VisionBuilder.Workflow/Hawkeye.VisionBuilder.Workflow.csproj b/Hawkeye.VisionBuilder.Workflow/Hawkeye.VisionBuilder.Workflow.csproj index 80b6571..b28da0c 100644 --- a/Hawkeye.VisionBuilder.Workflow/Hawkeye.VisionBuilder.Workflow.csproj +++ b/Hawkeye.VisionBuilder.Workflow/Hawkeye.VisionBuilder.Workflow.csproj @@ -5,7 +5,6 @@ enable enable True - x64 Debug;Release;CPU diff --git a/Plugins/CandyboxPlugin/Detectors/BlisterDetector.cs b/Plugins/CandyboxPlugin/Detectors/BlisterDetector.cs index 4b4a796..8029548 100644 --- a/Plugins/CandyboxPlugin/Detectors/BlisterDetector.cs +++ b/Plugins/CandyboxPlugin/Detectors/BlisterDetector.cs @@ -19,7 +19,7 @@ namespace CandyboxPlugin.Detectors // get this dll path var path=Assembly.GetCallingAssembly().Location; var dir=System.IO.Path.GetDirectoryName(path); - var modelPath = Path.Combine(dir,"models\\" + MODEL_NAME); + var modelPath = Path.Combine(dir,"models" , MODEL_NAME); _AIsession = new InferenceSession(modelPath, opts); _inputName = _AIsession.InputMetadata.First().Key; _dimensions = _AIsession.InputMetadata.First().Value.Dimensions; diff --git a/Plugins/CandyboxPlugin/Detectors/CandyDetector.cs b/Plugins/CandyboxPlugin/Detectors/CandyDetector.cs index 7b29f92..5dc4514 100644 --- a/Plugins/CandyboxPlugin/Detectors/CandyDetector.cs +++ b/Plugins/CandyboxPlugin/Detectors/CandyDetector.cs @@ -18,7 +18,7 @@ namespace CandyboxPlugin.Detectors // get this dll path var path = Assembly.GetCallingAssembly().Location; var dir = System.IO.Path.GetDirectoryName(path); - var modelPath = Path.Combine(dir, "models\\" + MODEL_NAME); + var modelPath = Path.Combine(dir, "models" , MODEL_NAME); _AIsession = new InferenceSession(modelPath, opts); _inputName = _AIsession.InputMetadata.First().Key; _dimensions = _AIsession.InputMetadata.First().Value.Dimensions; diff --git a/VisionBuilder.UI.Blazor.Uno/Components/Layout/MainLayout.razor.cs b/VisionBuilder.UI.Blazor.Uno/Components/Layout/MainLayout.razor.cs index 24f0c3d..a9d5a8e 100644 --- a/VisionBuilder.UI.Blazor.Uno/Components/Layout/MainLayout.razor.cs +++ b/VisionBuilder.UI.Blazor.Uno/Components/Layout/MainLayout.razor.cs @@ -47,6 +47,7 @@ public partial class MainLayout : IDisposable }; private MudTheme _currentTheme = null!; + private bool _disposed; protected override void OnInitialized() { @@ -71,6 +72,7 @@ public partial class MainLayout : IDisposable private async void OnPropertyChanged(object? sender, PropertyChangedEventArgs e) { + if (_disposed) return; if (e.PropertyName == nameof(MainWindowVM.TestMode)) { _testMode = MainWindowVm.TestMode; @@ -98,6 +100,7 @@ public partial class MainLayout : IDisposable public void Dispose() { + _disposed = true; MainWindowVm.PropertyChanged -= OnPropertyChanged; } } diff --git a/VisionBuilder.UI.Blazor.Uno/Program.cs b/VisionBuilder.UI.Blazor.Uno/Program.cs index 174612f..0550625 100644 --- a/VisionBuilder.UI.Blazor.Uno/Program.cs +++ b/VisionBuilder.UI.Blazor.Uno/Program.cs @@ -26,7 +26,7 @@ builder.Services.AddMudServices(); CommandLineParser commandLineParser = new CommandLineParser(args); // Setup settings -InspectronSettings settings = new InspectronSettings("..\\Data\\Config"); +InspectronSettings settings = new InspectronSettings(Path.Combine("..", "Data", "Config")); var mainKernel = VisionBuilder.UI.Common.VisionBuilder.CreateMainKernel(settings); diff --git a/VisionBuilder.UI.Blazor.Uno/VisionBuilder.UI.Blazor.Uno.csproj b/VisionBuilder.UI.Blazor.Uno/VisionBuilder.UI.Blazor.Uno.csproj index 2853896..a5937cd 100644 --- a/VisionBuilder.UI.Blazor.Uno/VisionBuilder.UI.Blazor.Uno.csproj +++ b/VisionBuilder.UI.Blazor.Uno/VisionBuilder.UI.Blazor.Uno.csproj @@ -16,6 +16,7 @@ + diff --git a/VisionBuilder.UI.Blazor/Components/ErrorPreview.razor.cs b/VisionBuilder.UI.Blazor/Components/ErrorPreview.razor.cs index 10f521e..e8a8ee7 100644 --- a/VisionBuilder.UI.Blazor/Components/ErrorPreview.razor.cs +++ b/VisionBuilder.UI.Blazor/Components/ErrorPreview.razor.cs @@ -12,6 +12,7 @@ public partial class ErrorPreview : ComponentBase, IDisposable private List _errors = new(); private ErrorsVM? _subscribedVm; + private bool _disposed; protected override void OnParametersSet() { @@ -41,6 +42,7 @@ public partial class ErrorPreview : ComponentBase, IDisposable private async void OnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) { + if (_disposed) return; if (ViewModel != null) _errors = new List(ViewModel.Errors); await InvokeAsync(StateHasChanged); @@ -54,6 +56,7 @@ public partial class ErrorPreview : ComponentBase, IDisposable public void Dispose() { + _disposed = true; Unsubscribe(); } } diff --git a/VisionBuilder.UI.Blazor/Components/PreviewWindow.razor.cs b/VisionBuilder.UI.Blazor/Components/PreviewWindow.razor.cs index 958ce22..f088742 100644 --- a/VisionBuilder.UI.Blazor/Components/PreviewWindow.razor.cs +++ b/VisionBuilder.UI.Blazor/Components/PreviewWindow.razor.cs @@ -15,6 +15,7 @@ public partial class PreviewWindow : ComponentBase, IDisposable private DateTime _lastRenderTime = DateTime.MinValue; private Timer? _pendingTimer; private PreviewVM? _subscribedVm; + private bool _disposed; protected override void OnParametersSet() { @@ -69,6 +70,8 @@ public partial class PreviewWindow : ComponentBase, IDisposable private async Task RenderCurrentFrame() { + if (_disposed) return; + _lastRenderTime = DateTime.UtcNow; var mat = ViewModel?.ImagePreview; @@ -88,6 +91,7 @@ public partial class PreviewWindow : ComponentBase, IDisposable public void Dispose() { + _disposed = true; _pendingTimer?.Dispose(); Unsubscribe(); } diff --git a/VisionBuilder.UI.Blazor/Components/SingleCameraControl.razor.cs b/VisionBuilder.UI.Blazor/Components/SingleCameraControl.razor.cs index 0ae3243..7712ed4 100644 --- a/VisionBuilder.UI.Blazor/Components/SingleCameraControl.razor.cs +++ b/VisionBuilder.UI.Blazor/Components/SingleCameraControl.razor.cs @@ -18,6 +18,7 @@ public partial class SingleCameraControl : ComponentBase, IDisposable private bool _canHotReload; private bool _showPauseButton; private SingleCameraVM? _subscribedVm; + private bool _disposed; protected override void OnParametersSet() { @@ -61,6 +62,7 @@ public partial class SingleCameraControl : ComponentBase, IDisposable private async void OnPropertyChanged(object? sender, PropertyChangedEventArgs e) { + if (_disposed) return; UpdateState(); await InvokeAsync(StateHasChanged); } @@ -103,6 +105,7 @@ public partial class SingleCameraControl : ComponentBase, IDisposable public void Dispose() { + _disposed = true; Unsubscribe(); } } diff --git a/VisionBuilder.UI.Blazor/Components/Stats.razor.cs b/VisionBuilder.UI.Blazor/Components/Stats.razor.cs index 236e515..9135c88 100644 --- a/VisionBuilder.UI.Blazor/Components/Stats.razor.cs +++ b/VisionBuilder.UI.Blazor/Components/Stats.razor.cs @@ -17,6 +17,7 @@ public partial class Stats : ComponentBase, IDisposable private string _errorRate = ""; private string _statisticsDetails = ""; private StatisticsVM? _subscribedVm; + private bool _disposed; protected override void OnParametersSet() { @@ -43,6 +44,8 @@ public partial class Stats : ComponentBase, IDisposable private async void OnPropertyChanged(object? sender, PropertyChangedEventArgs e) { + if (_disposed) return; + _sessionStarted = ViewModel?.SessionStarted ?? ""; _recipeName = ViewModel?.RecipeName ?? ""; _processingTime = ViewModel?.ProcessingTime ?? ""; @@ -57,6 +60,7 @@ public partial class Stats : ComponentBase, IDisposable public void Dispose() { + _disposed = true; Unsubscribe(); } } diff --git a/VisionBuilder.UI.Blazor/Dialogs/ImagePreviewDialog.razor b/VisionBuilder.UI.Blazor/Dialogs/ImagePreviewDialog.razor index 6873370..2304570 100644 --- a/VisionBuilder.UI.Blazor/Dialogs/ImagePreviewDialog.razor +++ b/VisionBuilder.UI.Blazor/Dialogs/ImagePreviewDialog.razor @@ -48,14 +48,24 @@ [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!; [Parameter] public ErrorPreviewVM? ViewModel { get; set; } + private ErrorPreviewVM? _subscribedVm; + private bool _disposed; + protected override void OnParametersSet() { - if (ViewModel != null) - ViewModel.PropertyChanged += OnPropertyChanged; + if (_subscribedVm != ViewModel) + { + if (_subscribedVm != null) + _subscribedVm.PropertyChanged -= OnPropertyChanged; + _subscribedVm = ViewModel; + if (ViewModel != null) + ViewModel.PropertyChanged += OnPropertyChanged; + } } private async void OnPropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) { + if (_disposed) return; await InvokeAsync(StateHasChanged); } @@ -72,7 +82,8 @@ public void Dispose() { - if (ViewModel != null) - ViewModel.PropertyChanged -= OnPropertyChanged; + _disposed = true; + if (_subscribedVm != null) + _subscribedVm.PropertyChanged -= OnPropertyChanged; } } diff --git a/VisionBuilder.UI.Recipes.HawkeyeRecipe/WorkflowRecipeHelper.cs b/VisionBuilder.UI.Recipes.HawkeyeRecipe/WorkflowRecipeHelper.cs index 77e97bc..11da87c 100644 --- a/VisionBuilder.UI.Recipes.HawkeyeRecipe/WorkflowRecipeHelper.cs +++ b/VisionBuilder.UI.Recipes.HawkeyeRecipe/WorkflowRecipeHelper.cs @@ -6,7 +6,7 @@ public static class WorkflowRecipeHelper { - private const string RECIPES_DIR = "..\\Data\\Recipes"; + private static string RECIPES_DIR => Path.Combine("..", "Data", "Recipes"); public static List ListRecipeFiles(string nameFilter) { Directory.CreateDirectory(RECIPES_DIR); diff --git a/VisionBuilder.UI.Ringbuffer/VisionBuilderRingbufferSettings.cs b/VisionBuilder.UI.Ringbuffer/VisionBuilderRingbufferSettings.cs index ec0d881..ad776cc 100644 --- a/VisionBuilder.UI.Ringbuffer/VisionBuilderRingbufferSettings.cs +++ b/VisionBuilder.UI.Ringbuffer/VisionBuilderRingbufferSettings.cs @@ -25,7 +25,7 @@ Specifies directory, in which MaxBad and MaxGood are applied. "+ PathSettingsUtils.INSTUCTIONS )] [SettingPreview(typeof(VisionBuilderRingbufferSettings), nameof(ImagesPathTemplatePreview))] - public string Root { get; set; } = @"..\Data\Ringbuffer\$SS_MONTH_NAME $SS_YEAR"; + public string Root { get; set; } = Path.Combine("..", "Data", "Ringbuffer", "$SS_MONTH_NAME $SS_YEAR"); diff --git a/VisionBuilder.UI.Statistics/VisionBuilderStatisticsSettings.cs b/VisionBuilder.UI.Statistics/VisionBuilderStatisticsSettings.cs index 0fee50e..d1f9091 100644 --- a/VisionBuilder.UI.Statistics/VisionBuilderStatisticsSettings.cs +++ b/VisionBuilder.UI.Statistics/VisionBuilderStatisticsSettings.cs @@ -20,7 +20,7 @@ Specifies directory, in which MaxBad and MaxGood are applied. "+PathSettingsUtils.INSTUCTIONS )] [SettingPreview(typeof(VisionBuilderStatisticsSettings), nameof(PathTemplatePreview))] - public string PathTemplate { get; set; }= @$"..\Data\Statistics\$SS_MONTH_NUM $SS_YEAR\$RECIPE_NAME\"; + public string PathTemplate { get; set; }= Path.Combine("..", "Data", "Statistics", "$SS_MONTH_NUM $SS_YEAR", "$RECIPE_NAME"); public string StartDateColumnName { get; set; } = "Start Date"; public string StartTimeColumnName { get; set; } = "Start time"; diff --git a/VisionBuilder.UI.Windows.Duo/Program.cs b/VisionBuilder.UI.Windows.Duo/Program.cs index db2d20d..9f0ae37 100644 --- a/VisionBuilder.UI.Windows.Duo/Program.cs +++ b/VisionBuilder.UI.Windows.Duo/Program.cs @@ -29,7 +29,7 @@ internal static class Program MaterialSkin.MaterialSkinManager.ConfigureForInspectron(); CommandLineParser commandLineParser = new CommandLineParser(args); - InspectronSettings settings = new InspectronSettings("..\\Data\\Config"); + InspectronSettings settings = new InspectronSettings(Path.Combine("..", "Data", "Config")); var mainKernel = VisionBuilder.UI.Common.VisionBuilder.CreateMainKernel(settings); var profile = commandLineParser.GetStringArgument("profile", 'p'); diff --git a/framework/Inspectron.Camera/Emulation/EmulationCamera.cs b/framework/Inspectron.Camera/Emulation/EmulationCamera.cs index 6803d7a..82e548c 100644 --- a/framework/Inspectron.Camera/Emulation/EmulationCamera.cs +++ b/framework/Inspectron.Camera/Emulation/EmulationCamera.cs @@ -32,7 +32,7 @@ namespace Inspectron.Camera.Emulation try { _currentFolder = imagesFolder; - var path = Path.Combine(@"..\Data\Emulation", imagesFolder); + var path = Path.Combine("..","Data","Emulation", imagesFolder); _selectedFiles = Directory.GetFiles(path, "*.bmp") .Concat(Directory.GetFiles(path, "*.png")) .Concat(Directory.GetFiles(path, "*.jpg"))