Skip to content

Commit

Permalink
Don't crash if we are unable to set auto-start
Browse files Browse the repository at this point in the history
This shouldn't happen, as it means that something allowed us to write
to the registry key on startup, but is denying us access when the settings
are saved. Show a MessageBox in this case.

Fixes #407
  • Loading branch information
canton7 committed Feb 28, 2018
1 parent 575b44e commit 35a54cf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/SyncTrayzor/Pages/Settings/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,19 @@ public void Save()

if (this.autostartProvider.CanWrite)
{
var autostartConfig = new AutostartConfiguration() { AutoStart = this.StartOnLogon, StartMinimized = this.StartMinimized };
this.autostartProvider.SetAutoStart(autostartConfig);
// I've seen this fail, even though we successfully wrote on startup
try
{
var autostartConfig = new AutostartConfiguration() { AutoStart = this.StartOnLogon, StartMinimized = this.StartMinimized };
this.autostartProvider.SetAutoStart(autostartConfig);
}
catch
{
this.windowManager.ShowMessageBox(
Resources.SettingsView_CannotSetAutoStart_Message,
Resources.SettingsView_CannotSetAutoStart_Title,
MessageBoxButton.OK, MessageBoxImage.Error);
}
}

if (this.settings.Any(x => x.HasChanged && x.RequiresSyncTrayzorRestart))
Expand Down
18 changes: 18 additions & 0 deletions src/SyncTrayzor/Properties/Resources.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 src/SyncTrayzor/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -985,4 +985,10 @@ Please donate to my charity fundraising campaign.</value>
<value>Note:</value>
<comment>Text shown in bold just before SettingsView_WatchedFolderEnabledInSyncthing</comment>
</data>
<data name="SettingsView_CannotSetAutoStart_Message" xml:space="preserve">
<value>Unable to set your auto-start settings. This is probably due to anti-virus software.</value>
</data>
<data name="SettingsView_CannotSetAutoStart_Title" xml:space="preserve">
<value>Unable to set auto-start</value>
</data>
</root>

0 comments on commit 35a54cf

Please sign in to comment.