Skip to content

Commit

Permalink
Dispose memory stream while updating icons (#14967)
Browse files Browse the repository at this point in the history
* comments

* comments
  • Loading branch information
zeusongit authored Feb 27, 2024
1 parent 664a2a1 commit 66a734e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 13 deletions.
39 changes: 37 additions & 2 deletions src/DynamoCoreWpf/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
abstract Dynamo.PackageManager.UI.PackageItemViewModel.Items.get -> System.Collections.ObjectModel.ObservableCollection<Dynamo.PackageManager.UI.PackageItemViewModel>
abstract Dynamo.PackageManager.UI.PackageItemViewModel.Items.get -> System.Collections.ObjectModel.ObservableCollection<Dynamo.PackageManager.UI.PackageItemViewModel>
abstract Dynamo.PackageManager.UI.PackageItemViewModel.Items.set -> void
abstract Dynamo.Wpf.Extensions.ViewExtensionBase.Dispose() -> void
abstract Dynamo.Wpf.Extensions.ViewExtensionBase.Name.get -> string
Expand Down Expand Up @@ -37,6 +37,10 @@ Dynamo.Controls.AutoLacingToVisibilityConverter
Dynamo.Controls.AutoLacingToVisibilityConverter.AutoLacingToVisibilityConverter() -> void
Dynamo.Controls.AutoLacingToVisibilityConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.AutoLacingToVisibilityConverter.ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.Base64ToImageConverter
Dynamo.Controls.Base64ToImageConverter.Base64ToImageConverter() -> void
Dynamo.Controls.Base64ToImageConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.Base64ToImageConverter.ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.BinaryRadioButtonCheckedConverter
Dynamo.Controls.BinaryRadioButtonCheckedConverter.BinaryRadioButtonCheckedConverter() -> void
Dynamo.Controls.BinaryRadioButtonCheckedConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Expand Down Expand Up @@ -3970,6 +3974,36 @@ Dynamo.Wpf.Views.CodeHighlightingRuleFactory
Dynamo.Wpf.Views.Debug.DebugModesWindow
Dynamo.Wpf.Views.Debug.DebugModesWindow.DebugModesWindow() -> void
Dynamo.Wpf.Views.Debug.DebugModesWindow.InitializeComponent() -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.InitializeComponent() -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.IsUpdateEnabled.get -> bool
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.IsUpdateEnabled.set -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NewIconPaths.get -> string
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NewIconPaths.set -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.IconName.get -> string
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.IconName.set -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.IconResxFile.get -> string
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.IconResxFile.set -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.IconSuffix.get -> string
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.IconSuffix.set -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.Icon_Base64String.get -> string
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.Icon_Base64String.set -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.IsUpdated.get -> bool
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.IsUpdated.set -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.NewIconPath.get -> string
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.NewIconPath.set -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.NodeIconMetadata(string nodeName, string newIconPath, string iconName, string iconSuffix, string oldData, string resxFile, bool isUpdated = false) -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.NodeName.get -> string
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.NodeName.set -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.OldData.get -> string
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata.OldData.set -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.Output.get -> string
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.Output.set -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.PropertyChanged -> System.ComponentModel.PropertyChangedEventHandler
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.UpdatedIconList.get -> System.Collections.ObjectModel.ObservableCollection<Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.NodeIconMetadata>
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.UpdatedIconList.set -> void
Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow.UpdateNodeIconsWindow(System.Collections.Generic.IEnumerable<Dynamo.Search.SearchElements.NodeSearchElement> entries) -> void
Dynamo.Wpf.Views.FileTrust.FileTrustWarning
Dynamo.Wpf.Views.FileTrust.FileTrustWarning.FileTrustWarning(Dynamo.Controls.DynamoView dynamoViewWindow) -> void
Dynamo.Wpf.Views.FileTrust.FileTrustWarning.InitializeComponent() -> void
Expand Down Expand Up @@ -5350,6 +5384,7 @@ static Dynamo.Wpf.Properties.Resources.UnloadFailureMessageBoxTitle.get -> strin
static Dynamo.Wpf.Properties.Resources.UnpinNodeTooltip.get -> string
static Dynamo.Wpf.Properties.Resources.UnsavedChangesMessageBoxTitle.get -> string
static Dynamo.Wpf.Properties.Resources.UpdateMessage.get -> string
static Dynamo.Wpf.Properties.Resources.UpdateNodeIconsDebugMenu.get -> string
static Dynamo.Wpf.Properties.Resources.UsageReportPromptDialogTitle.get -> string
static Dynamo.Wpf.Properties.Resources.UseLevelKeepListStructureHint.get -> string
static Dynamo.Wpf.Properties.Resources.UseLevelKeepListStructurePopupMenuItem.get -> string
Expand Down Expand Up @@ -5594,4 +5629,4 @@ virtual Dynamo.Wpf.ViewModels.Watch3D.DefaultWatch3DViewModel.UpdateHelpers() ->
virtual Dynamo.Wpf.ViewModels.Watch3D.DefaultWatch3DViewModel.ZoomToFit(object parameter) -> void
virtual Dynamo.Wpf.ViewModels.Watch3D.HelixWatch3DViewModel.OnWatchExecution() -> void
virtual Dynamo.Wpf.ViewModels.Watch3D.HelixWatch3DViewModel.UpdateUpstream() -> void
virtual UI.Prompts.PortPropertiesEditPrompt.OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e) -> void
virtual UI.Prompts.PortPropertiesEditPrompt.OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e) -> void
17 changes: 11 additions & 6 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3386,13 +3386,18 @@ public object Convert(object value, Type targetType, object parameter, System.Gl

if (string.IsNullOrEmpty(s)) return null;

BitmapImage bi = new BitmapImage();

bi.BeginInit();
bi.StreamSource = new MemoryStream(System.Convert.FromBase64String(s));
bi.EndInit();
BitmapImage loadedBitM = null;
using (MemoryStream ms = new MemoryStream(System.Convert.FromBase64String(s)))
{
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = ms;
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.EndInit();
loadedBitM = bi;
}

return bi;
return loadedBitM;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
Expand Down
10 changes: 5 additions & 5 deletions src/DynamoCoreWpf/Views/Debug/UpdateNodeIconsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
namespace Dynamo.Wpf.Views.Debug
{
/// <summary>
/// Interaction logic for DebugModesWindow.xaml
/// Interaction logic for UpdateNodeIconsWindow.xaml
/// </summary>
public partial class UpdateNodeIconsWindow : Window, INotifyPropertyChanged
{
#region properties
//The path that will be used to store log files related to this process
public static readonly string logPath = Path.Combine(Directory.GetCurrentDirectory(), @"NodeIconUpdateLog");
public string errorFile = Path.Combine(logPath, @"error_icons.csv");
public string logFile = Path.Combine(logPath, @"success_icons.csv");
private static readonly string logPath = Path.Combine(Directory.GetCurrentDirectory(), @"NodeIconUpdateLog");
private string errorFile = Path.Combine(logPath, @"error_icons.csv");
private string logFile = Path.Combine(logPath, @"success_icons.csv");


IEnumerable<NodeSearchElement> entries;

public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
internal void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
Expand Down

0 comments on commit 66a734e

Please sign in to comment.