From 0b64e3727bfbe5d4e5f134a52361ff3e5ed14a96 Mon Sep 17 00:00:00 2001 From: niksedk Date: Sat, 6 Oct 2012 14:07:57 +0000 Subject: [PATCH] Fixed crash when clicking on "Open" file... (first commit from 2012) git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1406 99eadd0c-20b8-1223-b5c4-2a2b2df33de2 --- src/Forms/Main.cs | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index ea45b7642..87916d518 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -160,6 +160,7 @@ namespace Nikse.SubtitleEdit.Forms private string _lastDoNotPrompt = string.Empty; private VideoInfo _videoInfo = null; bool _splitDualSami = false; + bool _openFileDialogOn = false; private bool AutoRepeatContinueOn { @@ -1899,21 +1900,39 @@ namespace Nikse.SubtitleEdit.Forms private void OpenToolStripMenuItemClick(object sender, EventArgs e) { + openToolStripMenuItem.Enabled = false; ReloadFromSourceView(); OpenNewFile(); + openToolStripMenuItem.Enabled = true; } private void OpenNewFile() - { + { + if (_openFileDialogOn) + return; + _openFileDialogOn = true; _lastDoNotPrompt = string.Empty; if (!ContinueNewOrExit()) + { + _openFileDialogOn = false; return; - openFileDialog1.Title = _languageGeneral.OpenSubtitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = Utilities.GetOpenDialogFilter(); - - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - OpenSubtitle(openFileDialog1.FileName, null); + } + try + { + openFileDialog1.Title = _languageGeneral.OpenSubtitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = Utilities.GetOpenDialogFilter(); + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + OpenSubtitle(openFileDialog1.FileName, null); + } + catch + { + System.Diagnostics.Debug.WriteLine("Open file exception - might be called multiple times?"); + } + finally + { + _openFileDialogOn = false; + } } public double CurrentFrameRate