Skip to content

Commit

Permalink
Version 1.3.1
Browse files Browse the repository at this point in the history
Fixed issue #34
Fixed issue #33 , which also fixes the Apply button
Moved the kill VM code from toolstrip item click event to VMKill() function
Added a try-catch block around p.Kill() just in case
  • Loading branch information
daviunic committed Dec 30, 2018
1 parent 7f99564 commit 4023ffb
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 14 deletions.
4 changes: 2 additions & 2 deletions 86BoxManager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,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.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyVersion("1.3.1.0")]
[assembly: AssemblyFileVersion("1.3.1.0")]
1 change: 1 addition & 0 deletions 86BoxManager/dlgSettings.Designer.cs

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

27 changes: 21 additions & 6 deletions 86BoxManager/dlgSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private void btnCancel_Click(object sender, EventArgs e)
private void btnApply_Click(object sender, EventArgs e)
{
SaveSettings();
btnApply.Enabled = false;
}

private void btnOK_Click(object sender, EventArgs e)
Expand All @@ -60,8 +61,7 @@ private void txt_TextChanged(object sender, EventArgs e)
}
else
{
//btnApply.Enabled = true;
settingsChanged = true;
settingsChanged = CheckForChanges(); //true;
btnOK.Enabled = true;
}
}
Expand Down Expand Up @@ -168,12 +168,12 @@ private void btnBrowse2_Click(object sender, EventArgs e)

private void cbxMinimize_CheckedChanged(object sender, EventArgs e)
{
settingsChanged = true;
settingsChanged = CheckForChanges();//true;
}

private void cbxShowConsole_CheckedChanged(object sender, EventArgs e)
{
settingsChanged = true;
settingsChanged = CheckForChanges();//true;
}

private void btnDefaults_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -201,12 +201,27 @@ private void ResetSettings()

private void cbxCloseTray_CheckedChanged(object sender, EventArgs e)
{
settingsChanged = true;
settingsChanged = CheckForChanges();//true;
}

private void cbxMinimizeTray_CheckedChanged(object sender, EventArgs e)
{
settingsChanged = true;
settingsChanged = CheckForChanges();//true;
}

//Checks if all controls match the currently saved settings to determine if any changes were made
private bool CheckForChanges()
{
RegistryKey regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box");

btnApply.Enabled = (txtEXEdir.Text != regkey.GetValue("EXEdir").ToString() ||
txtCFGdir.Text != regkey.GetValue("CFGdir").ToString() ||
cbxMinimize.Checked != Convert.ToBoolean(regkey.GetValue("MinimizeOnVMStart")) ||
cbxShowConsole.Checked != Convert.ToBoolean(regkey.GetValue("ShowConsole")) ||
cbxMinimizeTray.Checked != Convert.ToBoolean(regkey.GetValue("MinimizeToTray")) ||
cbxCloseTray.Checked != Convert.ToBoolean(regkey.GetValue("CloseToTray")));

return btnApply.Enabled;
}
}
}
24 changes: 18 additions & 6 deletions 86BoxManager/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ private void LoadVMs()
}

//Wait for the associated window of a VM to close
private void backgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
VM vm = e.Argument as VM;
try
Expand All @@ -264,7 +264,6 @@ private void backgroundWorker_DoWork(object sender, System.ComponentModel.DoWork
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 @@ -1090,8 +1089,8 @@ private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
return;
}
Application.Exit();
}
Application.Exit();
}

//Handles things when WindowState changes
Expand Down Expand Up @@ -1130,13 +1129,26 @@ private void settingsToolStripMenuItem_Click(object sender, EventArgs e)

private void killToolStripMenuItem_Click(object sender, EventArgs e)
{
//Ask the user to confirm and kill the VM's process
VMKill();
}

//Kills the process associated with the selected VM
private void VMKill()
{
//Ask the user to confirm
DialogResult = MessageBox.Show("Killing a virtual machine can cause data loss. Only do this if 86Box.exe process gets stuck. Do you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if(DialogResult == DialogResult.Yes)
if (DialogResult == DialogResult.Yes)
{
VM vm = (VM)lstVMs.FocusedItem.Tag;
Process p = Process.GetProcessById(vm.Pid);
p.Kill();
try
{
p.Kill();
}
catch (Exception ex)
{
MessageBox.Show("Could not kill 86Box.exe. The process may have already ended on its own or access was denied.", "Could not kill process", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

//We need to cleanup afterwards to make sure the VM is put back into a valid state
vm.Status = VM.STATUS_STOPPED;
Expand Down
4 changes: 4 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The following individuals or organizations have contributed at least some code to the 86Box Manager project:

David Simunič (@daviunic)
David Lee (@DL444)

0 comments on commit 4023ffb

Please sign in to comment.