mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Don't allow pressing stop/abort when process not running
This commit is contained in:
parent
f85e75f135
commit
91fec61141
4 changed files with 25 additions and 14 deletions
|
@ -36,6 +36,7 @@ public abstract class ExternalCLIManager : IDisposable
|
||||||
public event DataReceivedEventHandler ErrorDataReceived;
|
public event DataReceivedEventHandler ErrorDataReceived;
|
||||||
|
|
||||||
protected Process process;
|
protected Process process;
|
||||||
|
protected bool processRunning;
|
||||||
|
|
||||||
public virtual int Open(string path, string args = null)
|
public virtual int Open(string path, string args = null)
|
||||||
{
|
{
|
||||||
|
@ -63,7 +64,17 @@ public virtual int Open(string path, string args = null)
|
||||||
process.Start();
|
process.Start();
|
||||||
if (psi.RedirectStandardOutput) process.BeginOutputReadLine();
|
if (psi.RedirectStandardOutput) process.BeginOutputReadLine();
|
||||||
if (psi.RedirectStandardError) process.BeginErrorReadLine();
|
if (psi.RedirectStandardError) process.BeginErrorReadLine();
|
||||||
process.WaitForExit();
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
processRunning = true;
|
||||||
|
process.WaitForExit();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
processRunning = false;
|
||||||
|
}
|
||||||
|
|
||||||
return process.ExitCode;
|
return process.ExitCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +106,7 @@ private void cli_ErrorDataReceived(object sender, DataReceivedEventArgs e)
|
||||||
|
|
||||||
public void WriteInput(string input)
|
public void WriteInput(string input)
|
||||||
{
|
{
|
||||||
if (process != null && process.StartInfo != null && process.StartInfo.RedirectStandardInput)
|
if (processRunning && process != null && process.StartInfo != null && process.StartInfo.RedirectStandardInput)
|
||||||
{
|
{
|
||||||
process.StandardInput.WriteLine(input);
|
process.StandardInput.WriteLine(input);
|
||||||
}
|
}
|
||||||
|
@ -103,7 +114,7 @@ public void WriteInput(string input)
|
||||||
|
|
||||||
public virtual void Close()
|
public virtual void Close()
|
||||||
{
|
{
|
||||||
if (process != null)
|
if (processRunning && process != null)
|
||||||
{
|
{
|
||||||
process.CloseMainWindow();
|
process.CloseMainWindow();
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,14 +180,17 @@ public DirectShowDevices GetDirectShowDevices()
|
||||||
|
|
||||||
public override void Close()
|
public override void Close()
|
||||||
{
|
{
|
||||||
if (closeTryCount >= 2)
|
if (processRunning)
|
||||||
{
|
{
|
||||||
process.Kill();
|
if (closeTryCount >= 2)
|
||||||
}
|
{
|
||||||
else
|
process.Kill();
|
||||||
{
|
}
|
||||||
WriteInput("q");
|
else
|
||||||
closeTryCount++;
|
{
|
||||||
|
WriteInput("q");
|
||||||
|
closeTryCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ namespace ShareX.ScreenCaptureLib
|
||||||
public class ScreenRecorder : IDisposable
|
public class ScreenRecorder : IDisposable
|
||||||
{
|
{
|
||||||
public bool IsRecording { get; private set; }
|
public bool IsRecording { get; private set; }
|
||||||
public bool WriteCompressed { get; set; }
|
|
||||||
|
|
||||||
public int FPS
|
public int FPS
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,9 +94,7 @@ public static void Start()
|
||||||
|
|
||||||
private static void CubesForm_MouseClick(object sender, MouseEventArgs e)
|
private static void CubesForm_MouseClick(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
CompanionCube cube = Cubes.FirstOrDefault(x => x.Rectangle.Contains(e.Location));
|
foreach (CompanionCube cube in Cubes.Where(x => x.Rectangle.Contains(e.Location)))
|
||||||
|
|
||||||
if (cube != null)
|
|
||||||
{
|
{
|
||||||
cube.IsActive = false;
|
cube.IsActive = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue