Treat batch jobs with only 1 album as non-batch, i.e. allow interactive ui, such as repair dialog

This commit is contained in:
Grigory Chudov
2013-03-31 00:35:34 -04:00
parent 38721eddad
commit f3dfb02b60

View File

@@ -318,6 +318,7 @@ namespace JDP
private void frmCUETools_Load(object sender, EventArgs e) private void frmCUETools_Load(object sender, EventArgs e)
{ {
_batchPaths = new List<string>(); _batchPaths = new List<string>();
_batchProcessed = 0;
try try
{ {
_localDB = CUEToolsLocalDB.Load(); _localDB = CUEToolsLocalDB.Load();
@@ -511,7 +512,10 @@ namespace JDP
catch (Exception ex) catch (Exception ex)
{ {
if (!ShowErrorMessage(ex)) if (!ShowErrorMessage(ex))
{
_batchPaths.Clear(); _batchPaths.Clear();
_batchProcessed = 0;
}
if ((_workThread == null) && (_batchPaths.Count != 0)) if ((_workThread == null) && (_batchPaths.Count != 0))
{ {
_batchPaths.RemoveAt(0); _batchPaths.RemoveAt(0);
@@ -545,7 +549,7 @@ namespace JDP
private void MakeSelection(object sender, CUEToolsSelectionEventArgs e) private void MakeSelection(object sender, CUEToolsSelectionEventArgs e)
{ {
if (_batchPaths.Count != 0) if (_batchPaths.Count > 1 || _batchProcessed > 0)
return; return;
this.Invoke((MethodInvoker)delegate() this.Invoke((MethodInvoker)delegate()
{ {
@@ -766,6 +770,7 @@ namespace JDP
sw1.Write(cueSheetContents); sw1.Write(cueSheetContents);
sw1.Close(); sw1.Close();
BatchLog("created ok.", fullCueName); BatchLog("created ok.", fullCueName);
if (_batchPaths.Count > 0) _batchProcessed++;
} }
else else
{ {
@@ -840,6 +845,7 @@ namespace JDP
} }
else else
BatchLog("no changes.", pathIn); BatchLog("no changes.", pathIn);
if (_batchPaths.Count > 0) _batchProcessed++;
} }
else else
throw new Exception("invalid path"); throw new Exception("invalid path");
@@ -929,7 +935,7 @@ namespace JDP
toolStripStatusLabelAR.Visible = useAR; toolStripStatusLabelAR.Visible = useAR;
toolStripStatusLabelCTDB.Visible = useCUEToolsDB; toolStripStatusLabelCTDB.Visible = useCUEToolsDB;
if (_batchPaths.Count == 0 && action == CUEAction.Encode && (checkBoxUseFreeDb.Checked || checkBoxUseMusicBrainz.Checked)) if (_batchPaths.Count <= 1 && _batchProcessed == 0 && action == CUEAction.Encode && (checkBoxUseFreeDb.Checked || checkBoxUseMusicBrainz.Checked))
{ {
frmChoice dlg = new frmChoice(); frmChoice dlg = new frmChoice();
if (_choiceWidth != 0 && _choiceHeight != 0) if (_choiceWidth != 0 && _choiceHeight != 0)
@@ -1064,12 +1070,12 @@ namespace JDP
else else
status = cueSheet.ExecuteScript(script); status = cueSheet.ExecuteScript(script);
if (_batchPaths.Count > 0) if (_batchPaths.Count > 1 || _batchProcessed > 0)
{ {
_batchProcessed++;
BatchLog("{0}.", pathIn, status); BatchLog("{0}.", pathIn, status);
} }
cueSheet.CheckStop(); cueSheet.CheckStop();
if (_batchPaths.Count > 0) _batchProcessed++;
} }
} }
else else
@@ -1077,7 +1083,7 @@ namespace JDP
} }
this.Invoke((MethodInvoker)delegate() this.Invoke((MethodInvoker)delegate()
{ {
if (_batchPaths.Count == 0) if (_batchPaths.Count <= 1 && _batchProcessed <= 1)
{ {
if (cueSheet.IsCD) if (cueSheet.IsCD)
{ {
@@ -1129,7 +1135,6 @@ namespace JDP
} }
else else
{ {
_batchProcessed++;
String msg = ""; String msg = "";
for (Exception e = ex; e != null; e = e.InnerException) for (Exception e = ex; e != null; e = e.InnerException)
msg += ": " + e.Message; msg += ": " + e.Message;
@@ -1145,6 +1150,7 @@ namespace JDP
catch (StopException) catch (StopException)
{ {
_batchPaths.Clear(); _batchPaths.Clear();
_batchProcessed = 0;
this.Invoke((MethodInvoker)delegate() this.Invoke((MethodInvoker)delegate()
{ {
SetupControls(false); SetupControls(false);