提交 40c4dd70 编写于 作者: N Nicke Manarin

Memory leak fix. Also update translation.

上级 82bcb68a
......@@ -16,7 +16,8 @@ Fixed:
♦ Openning the Crop panel would cause a crash (if the new frame size was smaller).
♦ Getting new frames (by a new recording or by loading something else) while the Crop panel was open could throw an exception.
♦ Ocasionally, the playback buttons (play/pause, next, etc) would stay disabled (when it shouldn't).
♦ Ocasionally, the playback buttons (play/pause, next, etc) would stay disabled (when it shouldn't).
♦ The video importer was causing a memory leak.
Known Bugs:
......
......@@ -434,7 +434,8 @@
<s:String x:Key="Editor.DragDrop.Invalid.Title">Ungültiges Ziehen und Ablegen</s:String>
<s:String x:Key="Editor.DragDrop.MultipleFiles.Instruction">Sie können nicht mehrere Dateien gleichzeitig importieren</s:String>
<s:String x:Key="Editor.DragDrop.MultipleFiles.Message">Wählen Sie immer nur eine Datei aus.</s:String>
<s:String x:Key="Editor.DragDrop.Invalid.Instruction">Datei kann nicht geladen werden</s:String>
<s:String x:Key="Editor.DragDrop.Invalid.Message">Datei kann wegen ungültigen Formats nicht geladen werden.</s:String>
<s:String x:Key="Editor.DragDrop.InvalidProject.Instruction">Sie können nicht mehrere Projektdateien gleichzeitig importieren</s:String>
<s:String x:Key="Editor.DragDrop.InvalidProject.Message">Wählen Sie immer nur eine Projektdatei aus.</s:String>
......
......@@ -3840,7 +3840,7 @@ namespace ScreenToGif.Windows
foreach (var frame in frameList)
{
var frameName = Path.Combine(pathTemp, $"{count} {DateTime.Now.ToString("hh-mm-ss-FFFF")}.png");
var frameName = Path.Combine(pathTemp, $"{count} {DateTime.Now:hh-mm-ss-FFFF}.png");
using (var stream = new FileStream(frameName, FileMode.Create))
{
......@@ -3853,12 +3853,15 @@ namespace ScreenToGif.Windows
var frameInfo = new FrameInfo(frameName, delay);
frameInfoList.Add(frameInfo);
GC.Collect();
GC.Collect(1, GCCollectionMode.Forced);
count++;
UpdateProgress(count);
}
frameList.Clear();
GC.Collect();
#endregion
return frameInfoList;
......@@ -5749,4 +5752,4 @@ namespace ScreenToGif.Windows
// }
//}
}
}
}
\ No newline at end of file
......@@ -3,8 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:ScreenToGif.Controls"
xmlns:u="clr-namespace:ScreenToGif.Util"
Title="{DynamicResource ImportVideo.Title}" Height="500" Width="800" MinHeight="400" MinWidth="500" SnapsToDevicePixels="True" UseLayoutRounding="True"
Icon="/ScreenToGif;component/Resources/Logo.ico" WindowStartupLocation="CenterOwner">
Title="{DynamicResource ImportVideo.Title}" Height="500" Width="800" MinHeight="400" MinWidth="500"
SnapsToDevicePixels="True" UseLayoutRounding="True" Icon="/ScreenToGif;component/Resources/Logo.ico" WindowStartupLocation="CenterOwner"
Closing="Window_Closing">
<Grid>
<Grid.RowDefinitions>
......
......@@ -15,8 +15,8 @@ namespace ScreenToGif.Windows.Other
private bool _cancelled;
private int _playerLoadedCount = 0;
private readonly MediaPlayer _lowerPlayer = new MediaPlayer() { Volume = 0, ScrubbingEnabled = true };
private readonly MediaPlayer _upperPlayer = new MediaPlayer() { Volume = 0, ScrubbingEnabled = true };
private MediaPlayer _lowerPlayer = new MediaPlayer { Volume = 0, ScrubbingEnabled = true };
private MediaPlayer _upperPlayer = new MediaPlayer { Volume = 0, ScrubbingEnabled = true };
private readonly Queue<TimeSpan> _positions = new Queue<TimeSpan>();
private int _width;
......@@ -53,8 +53,6 @@ namespace ScreenToGif.Windows.Other
_loadVideoDel.BeginInvoke(new Uri(fileName), LoadFramesCallback, null);
}
#region Async
#region Load
private delegate bool LoadVideo(Uri file);
......@@ -100,9 +98,7 @@ namespace ScreenToGif.Windows.Other
}
#endregion
#endregion
#region Events
private void LowerMediaplayer_MediaOpened(object sender, EventArgs e)
......@@ -210,6 +206,8 @@ namespace ScreenToGif.Windows.Other
#endregion
CaptureFrames();
GC.Collect();
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
......@@ -223,6 +221,17 @@ namespace ScreenToGif.Windows.Other
DialogResult = false;
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
_lowerPlayer?.Close();
_upperPlayer?.Close();
_lowerPlayer = null;
_upperPlayer = null;
GC.Collect();
}
#endregion
#region Methods
......@@ -319,9 +328,7 @@ namespace ScreenToGif.Windows.Other
//Calculate all positions.
for (var span = SelectionSlider.LowerValue + Delay; span <= SelectionSlider.UpperValue; span += Delay)
{
_positions.Enqueue(TimeSpan.FromMilliseconds(span));
}
CaptureProgressBar.Maximum = _positions.Count;
CaptureProgressBar.Value = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册