From: sr55 <sr55.hb@outlook.com> Date: Sat, 24 May 2014 17:25:48 +0000 (+0000) Subject: WinGui: Don't grab previews when the preview window hasn't been opened. (Note, there... X-Git-Tag: 0.10.0~326 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ab2cefc88f522c02817a248e2b8d964d186c04f;p=handbrake WinGui: Don't grab previews when the preview window hasn't been opened. (Note, there is still a crash that sometimes happens for some resolutions that needs fixed, but the UI shouldn't crash anymore if the window hasn't been opened) git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6205 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs index a1d6b465c..6d42d4d55 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs @@ -23,5 +23,10 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// The task. /// </param> void UpdatePreviewFrame(EncodeTask task); + + /// <summary> + /// Gets or sets a value indicating whether is open. + /// </summary> + bool IsOpen { get; set; } } } diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs index b10c0f292..51c018ad9 100644 --- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs @@ -12,6 +12,7 @@ namespace HandBrakeWPF.ViewModels using System; using System.Collections.Generic; using System.Globalization; + using System.Windows; using System.Windows.Media.Imaging; using Caliburn.Micro; @@ -825,6 +826,7 @@ namespace HandBrakeWPF.ViewModels { if (!string.IsNullOrEmpty(this.Task.Source)) { + this.StaticPreviewViewModel.IsOpen = true; this.StaticPreviewViewModel.UpdatePreviewFrame(this.Task); this.WindowManager.ShowWindow(this.StaticPreviewViewModel); } @@ -1197,7 +1199,7 @@ namespace HandBrakeWPF.ViewModels /// </summary> private void UpdatePreviewImage() { - if (delayedPreviewprocessor != null && this.Task != null) + if (delayedPreviewprocessor != null && this.Task != null && this.StaticPreviewViewModel != null && this.StaticPreviewViewModel.IsOpen) { delayedPreviewprocessor.PerformTask(() => this.StaticPreviewViewModel.UpdatePreviewFrame(this.Task), 800); } diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs index 279cc6fc8..622319f61 100644 --- a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs @@ -194,6 +194,11 @@ namespace HandBrakeWPF.ViewModels this.Title = Properties.Resources.Preview; } + /// <summary> + /// Gets or sets a value indicating whether is open. + /// </summary> + public bool IsOpen { get; set; } + /// <summary> /// The update preview frame. /// </summary>