Skip to content

Commit c8469e9

Browse files
committed
Prevent Startup Crash from Null Object
1 parent b225575 commit c8469e9

File tree

6 files changed

+34
-22
lines changed

6 files changed

+34
-22
lines changed

Files UWP/App.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public App()
2222
this.InitializeComponent();
2323
this.Suspending += OnSuspending;
2424
this.UnhandledException += App_UnhandledException;
25-
2625
Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
2726

2827
if (localSettings.Values["theme"] != null)

Files UWP/ProHome.xaml.cs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,19 @@ public ProHome()
9696
}
9797

9898
// Overwrite paths for common locations if Custom Locations setting is enabled
99-
if (localSettings.Values["customLocationsSetting"].Equals(true))
99+
if(localSettings.Values["customLocationsSetting"] != null)
100100
{
101-
DesktopPath = localSettings.Values["DesktopLocation"].ToString();
102-
DownloadsPath = localSettings.Values["DownloadsLocation"].ToString();
103-
DocumentsPath = localSettings.Values["DocumentsLocation"].ToString();
104-
PicturesPath = localSettings.Values["PicturesLocation"].ToString();
105-
MusicPath = localSettings.Values["MusicLocation"].ToString();
106-
VideosPath = localSettings.Values["VideosLocation"].ToString();
101+
if (localSettings.Values["customLocationsSetting"].Equals(true))
102+
{
103+
DesktopPath = localSettings.Values["DesktopLocation"].ToString();
104+
DownloadsPath = localSettings.Values["DownloadsLocation"].ToString();
105+
DocumentsPath = localSettings.Values["DocumentsLocation"].ToString();
106+
PicturesPath = localSettings.Values["PicturesLocation"].ToString();
107+
MusicPath = localSettings.Values["MusicLocation"].ToString();
108+
VideosPath = localSettings.Values["VideosLocation"].ToString();
109+
}
107110
}
111+
108112

109113
}
110114

@@ -114,8 +118,17 @@ public ProHome()
114118

115119
public async void PopulatePinnedSidebarItems()
116120
{
121+
StorageFile ListFile;
117122
StorageFolder cacheFolder = Windows.Storage.ApplicationData.Current.LocalCacheFolder;
118-
var ListFile = await cacheFolder.GetFileAsync("PinnedItems.txt");
123+
try
124+
{
125+
ListFile = await cacheFolder.GetFileAsync("PinnedItems.txt");
126+
}
127+
catch(FileNotFoundException)
128+
{
129+
ListFile = await cacheFolder.CreateFileAsync("PinnedItems.txt");
130+
}
131+
119132
if(ListFile != null)
120133
{
121134
var ListFileLines = await FileIO.ReadLinesAsync(ListFile);

Files UWP/SettingsPages/About.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<TextBlock x:Name="Header" Text="Files UWP" Margin="0,0,0,5" FontFamily="Segoe UI Black" FontWeight="Bold" FontSize="40" HorizontalAlignment="Left" VerticalAlignment="Top" />
1616
<TextBlock Margin="0,0,0,5" FontFamily="Segoe UI" FontSize="20" Text="Product Information"/>
1717
<TextBlock FontSize="14" Text="Edition: Pre-Release"/>
18-
<TextBlock FontSize="14" Text="Version: 0.5.0-newui_snapshot1"/>
18+
<TextBlock FontSize="14" Text="Version: 0.5.0-newui_snapshot3-internal"/>
1919
<ListView IsItemClickEnabled="True" Margin="0,24,0,0" ItemClick="ListView_ItemClick" HorizontalAlignment="Left" Width="875">
2020
<ListViewItem IsEnabled="True" Name="FeedbackForm" Height="65" HorizontalAlignment="Stretch">
2121
<StackPanel Orientation="Horizontal">

Files UWP/UnhandledExceptionDisplay.xaml.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@
1515
using Windows.UI.Xaml.Media;
1616
using Windows.UI.Xaml.Navigation;
1717

18-
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
1918

2019
namespace Files
2120
{
22-
/// <summary>
23-
/// An empty page that can be used on its own or navigated to within a Frame.
24-
/// </summary>
2521
public sealed partial class UnhandledExceptionDisplay : Page
2622
{
2723
public UnhandledExceptionDisplay()
@@ -35,7 +31,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
3531
{
3632
base.OnNavigatedTo(eventArgs);
3733
var Parameter = eventArgs.Parameter as Exception;
38-
Summary.Text = Parameter.Message;
34+
Summary.Text = Parameter.Message + " within " + Parameter.TargetSite;
3935
ErrorInfo.Text = Parameter.StackTrace;
4036
}
4137

Files UWP/YourHome.xaml.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,17 @@ public YourHome()
4141

4242
// Overwrite paths for common locations if Custom Locations setting is enabled
4343
ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
44-
if (localSettings.Values["customLocationsSetting"].Equals(true))
44+
if (localSettings.Values["customLocationsSetting"] != null)
4545
{
46-
DesktopPath = localSettings.Values["DesktopLocation"].ToString();
47-
DownloadsPath = localSettings.Values["DownloadsLocation"].ToString();
48-
DocumentsPath = localSettings.Values["DocumentsLocation"].ToString();
49-
PicturesPath = localSettings.Values["PicturesLocation"].ToString();
50-
MusicPath = localSettings.Values["MusicLocation"].ToString();
51-
VideosPath = localSettings.Values["VideosLocation"].ToString();
46+
if (localSettings.Values["customLocationsSetting"].Equals(true))
47+
{
48+
DesktopPath = localSettings.Values["DesktopLocation"].ToString();
49+
DownloadsPath = localSettings.Values["DownloadsLocation"].ToString();
50+
DocumentsPath = localSettings.Values["DocumentsLocation"].ToString();
51+
PicturesPath = localSettings.Values["PicturesLocation"].ToString();
52+
MusicPath = localSettings.Values["MusicLocation"].ToString();
53+
VideosPath = localSettings.Values["VideosLocation"].ToString();
54+
}
5255
}
5356
}
5457

FilesUwp.Package/FilesUwp.Package.wapproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<AppInstallerUpdateFrequency>1</AppInstallerUpdateFrequency>
5555
<AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
5656
<AppxPackageDir>C:\builds\</AppxPackageDir>
57+
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
5758
</PropertyGroup>
5859
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
5960
<AppxBundle>Never</AppxBundle>

0 commit comments

Comments
 (0)