Skip to content

Commit cb707b4

Browse files
committed
fix: Fix ArgumentOutOfBoundException in updater
Don't rely on presence of hyphen for version parsing. Fixes#289
1 parent 2a225eb commit cb707b4

File tree

2 files changed

+53
-43
lines changed

2 files changed

+53
-43
lines changed

Buttplug.Components.Controls/ButtplugAboutControl.xaml.cs

+47-43
Original file line numberDiff line numberDiff line change
@@ -170,60 +170,64 @@ private void CheckForUpdates_Click(object sender, RoutedEventArgs e)
170170

171171
varjson=JObject.Parse(html);
172172
varlatest=json[_appName]["version"]?.ToString();
173-
if(latest!=null)
173+
if(latest==null)
174174
{
175-
varnumericVer=AboutVersionNumber.Text.Substring(0,AboutVersionNumber.Text.IndexOf('-'));
176-
varcVer=Version.Parse(numericVer);
177-
varlVer=Version.Parse(latest);
178-
179-
// Reverse this sign to test
180-
if(cVer.CompareTo(lVer)<0)
175+
return;
176+
}
177+
// Why isn't this just using the AssemblyVersion?!?!
178+
vardashPosition=AboutVersionNumber.Text.IndexOf('-');
179+
stringnumericVer;
180+
numericVer=dashPosition>=0?AboutVersionNumber.Text.Substring(0,dashPosition):AboutVersionNumber.Text;
181+
varcVer=Version.Parse(numericVer);
182+
varlVer=Version.Parse(latest);
183+
184+
// Reverse this sign to test
185+
if(cVer.CompareTo(lVer)<0)
186+
{
187+
// Update available
188+
UpdateCheckStatus.Text="Update Available! ("+DateTime.Now.ToString()+")";
189+
Hyperlinkhyperlink=null;
190+
try
181191
{
182-
// Update available
183-
UpdateCheckStatus.Text="Update Available! ("+DateTime.Now.ToString()+")";
184-
Hyperlinkhyperlink=null;
185-
try
192+
varlocation=json[_appName]["location"]?.ToString();
193+
if(location!=null)
186194
{
187-
varlocation=json[_appName]["location"]?.ToString();
188-
if(location!=null)
195+
hyperlink=newHyperlink(newRun(location))
189196
{
190-
hyperlink=newHyperlink(newRun(location))
191-
{
192-
NavigateUri=newUri(location),
193-
};
194-
hyperlink.RequestNavigate+=Hyperlink_RequestNavigate;
195-
UpdateCheckStatus.Text+="\n";
196-
UpdateCheckStatus.Inlines.Add(hyperlink);
197-
}
198-
}
199-
catch
200-
{
201-
// noop - there was an update, we just don't know where
197+
NavigateUri=newUri(location),
198+
};
199+
hyperlink.RequestNavigate+=Hyperlink_RequestNavigate;
200+
UpdateCheckStatus.Text+="\n";
201+
UpdateCheckStatus.Inlines.Add(hyperlink);
202202
}
203+
}
204+
catch
205+
{
206+
// noop - there was an update, we just don't know where
207+
}
203208

204-
if(MessageBox.Show("A new buttplug update is available! Would you like to go to the update site?",
205-
"Buttplug Update",
206-
MessageBoxButton.YesNo,
207-
MessageBoxImage.Asterisk)==MessageBoxResult.Yes)
208-
{
209-
hyperlink?.DoClick();
210-
}
209+
if(MessageBox.Show("A new buttplug update is available! Would you like to go to the update site?",
210+
"Buttplug Update",
211+
MessageBoxButton.YesNo,
212+
MessageBoxImage.Asterisk)==MessageBoxResult.Yes)
213+
{
214+
hyperlink?.DoClick();
215+
}
211216

212-
try
213-
{
214-
((TabControl)((TabItem)Parent).Parent).SelectedItem=Parent;
215-
UpdateCheckStatus.Focus();
216-
}
217-
catch
218-
{
219-
// noop - things went bang
220-
}
217+
try
218+
{
219+
((TabControl)((TabItem)Parent).Parent).SelectedItem=Parent;
220+
UpdateCheckStatus.Focus();
221221
}
222-
else
222+
catch
223223
{
224-
UpdateCheckStatus.Text="No new updates! ("+DateTime.Now.ToString()+")";
224+
// noop - things went bang
225225
}
226226
}
227+
else
228+
{
229+
UpdateCheckStatus.Text="No new updates! ("+DateTime.Now.ToString()+")";
230+
}
227231
}
228232
catch(Exceptionex)
229233
{

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 0.1.2 (2017-09-15)
2+
3+
## Bugfixes
4+
5+
- Fix ArgumentOutOfBoundsException in updater
6+
17
# 0.1.1 (2017-09-15)
28

39
## Features

0 commit comments

Comments
 (0)
close