Skip to content

Commit

Permalink
fix crash when opening options on mono, fixes #51
Browse files Browse the repository at this point in the history
  • Loading branch information
smorks committed Jun 8, 2020
1 parent 16fea3e commit d2dc3bc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 27 deletions.
29 changes: 14 additions & 15 deletions KeePassNatMsg/Options/OptionsForm.Designer.cs

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

38 changes: 26 additions & 12 deletions KeePassNatMsg/Options/OptionsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ private void okButton_Click(object sender, EventArgs e)
MessageBoxIcon.Information
);
}

DialogResult = DialogResult.OK;
Close();
}

private void cancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}

private void removeButton_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -229,7 +238,7 @@ private void btnInstallNativeMessaging_Click(object sender, EventArgs e)
_host.Install(bsf.SelectedBrowsers);
_host.UpdateProxy();
GetNativeMessagingStatus();
MessageBox.Show(this, "The native messaging host installed completed successfully.", "Install Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
Invoke(new Action(() => MessageBox.Show(this, "The native messaging host installed completed successfully.", "Install Complete", MessageBoxButtons.OK, MessageBoxIcon.Information)));
});
t.Start();
}
Expand All @@ -243,17 +252,7 @@ private void CheckNativeMessagingHost()
{
if (ti.IsCompleted && !ti.Result)
{
var nmiInstall = MessageBox.Show(this, $"The native messaging host was not detected. It must be installed for KeePassNatMsg to work. Do you want to install it now?", "Native Messaging Host Not Detected", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
if (nmiInstall == DialogResult.Yes)
{
var bsf = new BrowserSelectForm(_host);
if (bsf.ShowDialog(this) == DialogResult.OK)
{
_host.Install(bsf.SelectedBrowsers);
_host.UpdateProxy();
MessageBox.Show(this, "The native messaging host installed completed successfully.", "Install Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
Invoke(new Action(() => PromptInstall()));
}
GetNativeMessagingStatus();
});
Expand All @@ -263,6 +262,21 @@ private void CheckNativeMessagingHost()
t.Start();
}

private void PromptInstall()
{
var nmiInstall = MessageBox.Show(this, $"The native messaging host was not detected. It must be installed for KeePassNatMsg to work. Do you want to install it now?", "Native Messaging Host Not Detected", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
if (nmiInstall == DialogResult.Yes)
{
var bsf = new BrowserSelectForm(_host);
if (bsf.ShowDialog(this) == DialogResult.OK)
{
_host.Install(bsf.SelectedBrowsers);
_host.UpdateProxy();
MessageBox.Show(this, "The native messaging host installed completed successfully.", "Install Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}

private void OptionsForm_Shown(object sender, EventArgs e)
{
_host = NativeMessagingHost.GetHost();
Expand Down

0 comments on commit d2dc3bc

Please sign in to comment.