Skip to content

Commit

Permalink
Error Reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatNerdUKnow committed Nov 1, 2022
1 parent 4c8db51 commit cd6b3b7
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 32 deletions.
6 changes: 3 additions & 3 deletions vmaf-gui/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>
</configuration>
42 changes: 29 additions & 13 deletions vmaf-gui/Form1.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
Expand All @@ -14,6 +15,17 @@ public Form1()
InitializeComponent();
}

private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
processHandles.ForEach((handle) =>
{
handle.Close();
});
currentThread.Abort();
}

private List<Process> processHandles = new List<Process>();
private Thread currentThread;

string ChildProcess(string program_name, string args, bool show)
{
Expand All @@ -39,17 +51,17 @@ string ChildProcess(string program_name, string args, bool show)

Console.WriteLine(program_name);
Console.WriteLine(args);

processHandles.Add(p);
p.WaitForExit();

int exitCode = p.ExitCode;

if(exitCode != 0)
if (exitCode != 0)
{
throw new Exception(p.StandardError.ReadToEnd());
}



return output;
}
Expand Down Expand Up @@ -141,7 +153,7 @@ private void button1_Click(object sender, EventArgs e)
bool psnr = false;
bool ssim = false;



// Define what functions the thread does
ThreadStart tStart = new ThreadStart(
Expand Down Expand Up @@ -179,14 +191,16 @@ private void button1_Click(object sender, EventArgs e)
results resultsForm = new results();
resultsForm.showResults("./log.xml");
resultsForm.ShowDialog();
}catch
}
catch (Exception err)
{
prgProgress.Invoke(new Action(delegate () {
prgProgress.Invoke(new Action(delegate ()
{
prgProgress.Value = 0;
}));
lblProgress.Invoke(new Action(delegate () { lblProgress.Text = "There was a problem running VMAF"; }));
button1.Invoke(new Action(delegate () { button1.Enabled = true; }));

MessageBox.Show(err.ToString(),"VMAF-GUI",MessageBoxButtons.OK,MessageBoxIcon.Error);

}

Expand All @@ -195,12 +209,12 @@ private void button1_Click(object sender, EventArgs e)
);

// Define the thread and start it
Thread t = new Thread(tStart);
t.Start();
currentThread = new Thread(tStart);
currentThread.Start();
}
catch (Exception err)
{

MessageBox.Show(err.Message);
}
}
Expand Down Expand Up @@ -243,11 +257,13 @@ void vmaf(string resolution, string model, bool psnr, bool ssim)
}*/

lblProgress.Invoke(new Action(delegate () { lblProgress.Text = "Performing VMAF..."; }));
try{
try
{
ChildProcess("vmaf.exe", args, false);
}catch(Exception err)
}
catch (Exception err)
{
MessageBox.Show(err.Message,"There was a problem with VMAF");
MessageBox.Show(err.Message, "There was a problem with VMAF");
throw new Exception();
}

Expand Down
2 changes: 1 addition & 1 deletion vmaf-gui/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 9 additions & 13 deletions vmaf-gui/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions vmaf-gui/vmaf-gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType>
<RootNamespace>vmaf_gui</RootNamespace>
<AssemblyName>vmaf-gui</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
Expand All @@ -28,6 +28,7 @@
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -58,7 +59,7 @@
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
Expand All @@ -76,6 +77,7 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
Expand Down

0 comments on commit cd6b3b7

Please sign in to comment.