Skip to content

Commit

Permalink
Fix null ref when config file doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Noisyfox committed Jul 25, 2017
1 parent cf83598 commit 60b5254
Showing 1 changed file with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,49 @@ private void ControllerOnTranslateProviderChanged(bool fromView, string provider
return;
}

comboBoxProvider.SelectedValue = provider;
if (comboBoxProvider.SelectedIndex == -1)
if (string.IsNullOrEmpty(provider))
{
comboBoxProvider.SelectedIndex = 0;
}
else
{
comboBoxProvider.SelectedValue = provider;
if (comboBoxProvider.SelectedIndex == -1)
{
comboBoxProvider.SelectedIndex = 0;
}
}

textBoxApiKey.Text = apiKey;
if (!string.IsNullOrEmpty(apiKey))
{
textBoxApiKey.Text = apiKey;
}

comboBoxLangFrom.SelectedValue = langFrom;
if (comboBoxLangFrom.SelectedIndex == -1)
if (string.IsNullOrEmpty(langFrom))
{
comboBoxLangFrom.SelectedIndex = 0;
}
comboBoxLangTo.SelectedValue = langTo;
if (comboBoxLangTo.SelectedIndex == -1)
else
{
comboBoxLangFrom.SelectedValue = langFrom;
if (comboBoxLangFrom.SelectedIndex == -1)
{
comboBoxLangFrom.SelectedIndex = 0;
}
}

if (string.IsNullOrEmpty(langTo))
{
comboBoxLangTo.SelectedIndex = 0;
}
else
{
comboBoxLangTo.SelectedValue = langTo;
if (comboBoxLangTo.SelectedIndex == -1)
{
comboBoxLangTo.SelectedIndex = 0;
}
}
_plugin.Controller.NotifyTranslateProviderChanged(true, (string)comboBoxProvider.SelectedValue,
textBoxApiKey.Text, (string)comboBoxLangFrom.SelectedValue, (string)comboBoxLangTo.SelectedValue);
}
Expand Down

0 comments on commit 60b5254

Please sign in to comment.