Skip to content

Commit

Permalink
Fixed issue #10, other minor change
Browse files Browse the repository at this point in the history
Fixed issue where using Configure option for stopped VMs would cause process related errors
Version number in About dialog is now pulled from the assembly
  • Loading branch information
daviunic committed Oct 14, 2018
1 parent d1f7f1b commit 0e0098a
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 33 deletions.
1 change: 1 addition & 0 deletions 86BoxManager/86BoxManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Resources\86Box.ico</ApplicationIcon>
Expand Down
2 changes: 0 additions & 2 deletions 86BoxManager/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows.Forms;

namespace _86boxManager
Expand Down
4 changes: 2 additions & 2 deletions 86BoxManager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2.0")]
5 changes: 3 additions & 2 deletions 86BoxManager/dlgAbout.Designer.cs

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

6 changes: 6 additions & 0 deletions 86BoxManager/dlgAbout.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Reflection;
using System.Windows.Forms;

namespace _86boxManager
Expand Down Expand Up @@ -27,5 +28,10 @@ private void lnkGuthub2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs
lnkGithub2.LinkVisited = true;
System.Diagnostics.Process.Start("https://github.com/86Box/86Box");
}

private void dlgAbout_Load(object sender, EventArgs e)
{
lblVersion1.Text = Application.ProductVersion.ToString().TrimEnd('.', '0');
}
}
}
78 changes: 51 additions & 27 deletions 86BoxManager/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,17 @@ private void LoadVMs()
private void backgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
VM vm = e.Argument as VM;
Process p = Process.GetProcessById(vm.Pid); //Find the process associated with the VM
p.WaitForExit(); //Wait for it to exit
try
{
Process p = Process.GetProcessById(vm.Pid); //Find the process associated with the VM
p.WaitForExit(); //Wait for it to exit
}
catch(Exception ex)
{
MessageBox.Show("An error has occurred. Please provide the following details to the developer:\n" + ex.Message + "\n" + ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
e.Result = vm;

}

//Update the UI once the VM's window is closed
Expand Down Expand Up @@ -339,10 +347,15 @@ private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
if (vm.Status != VM.STATUS_STOPPED)
{
e.Cancel = true;
DialogResult = MessageBox.Show("It appears some virtual machines are still running. It's recommended you close those first before closing 86Box Manager. Do you want to continue anyway?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
DialogResult = MessageBox.Show("It appears some virtual machines are still running. It's recommended you close those first before closing 86Box Manager. Do you want to exit 86Box Manager anyway?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (DialogResult == DialogResult.Yes)
{
e.Cancel = false;
return; //We only need to display the warning once...
}
else if(DialogResult == DialogResult.No)
{
break;
}
}
}
Expand Down Expand Up @@ -509,32 +522,43 @@ private void VMConfigure()
}
else if (vm.Status == VM.STATUS_STOPPED)
{
Process p = Process.Start(exepath + "86Box.exe", "-S -P " + lstVMs.FocusedItem.SubItems[2].Text);
p.WaitForInputIdle();
vm.Status = VM.STATUS_IN_SETTINGS;
vm.hWnd = p.MainWindowHandle;
vm.Pid = p.Id;
lstVMs.FocusedItem.SubItems[1].Text = vm.GetStatusString();
lstVMs.FocusedItem.ImageIndex = 2;

BackgroundWorker bgw = new BackgroundWorker
try
{
WorkerReportsProgress = false,
WorkerSupportsCancellation = false
};
bgw.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);
bgw.RunWorkerAsync(vm);
Process p = Process.Start(exepath + "86Box.exe", "-S -P \"" + lstVMs.FocusedItem.SubItems[2].Text + "\"");
p.WaitForInputIdle();
vm.Status = VM.STATUS_IN_SETTINGS;
vm.hWnd = p.MainWindowHandle;
vm.Pid = p.Id;
lstVMs.FocusedItem.SubItems[1].Text = vm.GetStatusString();
lstVMs.FocusedItem.ImageIndex = 2;

BackgroundWorker bgw = new BackgroundWorker
{
WorkerReportsProgress = false,
WorkerSupportsCancellation = false
};
bgw.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);
bgw.RunWorkerAsync(vm);

btnStart.Enabled = false;
btnStart.Text = "Start";
btnEdit.Enabled = false;
btnDelete.Enabled = false;
btnConfigure.Enabled = false;
btnReset.Enabled = false;
btnPause.Enabled = false;
btnPause.Text = "Pause";
btnCtrlAltDel.Enabled = false;
btnStart.Enabled = false;
btnStart.Text = "Start";
btnEdit.Enabled = false;
btnDelete.Enabled = false;
btnConfigure.Enabled = false;
btnReset.Enabled = false;
btnPause.Enabled = false;
btnPause.Text = "Pause";
btnCtrlAltDel.Enabled = false;
}
catch(Exception ex)
{
//Revert to stopped status and alert the user
vm.Status = VM.STATUS_STOPPED;
vm.hWnd = IntPtr.Zero;
vm.Pid = -1;
MessageBox.Show("This virtual machine could not be started. Please provide the following information to the developer:\n" + ex.Message + "\n" + ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

Expand Down

0 comments on commit 0e0098a

Please sign in to comment.