-
Notifications
You must be signed in to change notification settings - Fork 564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More nullable checks and fixed minor bugs #378
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR!
Most of the changes are unnecessary as explained in the comments. Please either undo them or place the DisplayVersion fix and other fixes to confirmed issues in a separate PR.
var valueNames = targetKey.GetValueNames(); | ||
var valueNames = targetKey?.GetValueNames(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the check added this will throw a nullreference in the next line instead.
@@ -549,7 +549,7 @@ public void UninstallFromDirectory(IEnumerable<ApplicationUninstallerEntry> allU | |||
if (item.UninstallPossible && item.UninstallerKind != UninstallerType.SimpleDelete && | |||
MessageBoxes.UninstallFromDirectoryUninstallerFound(item.DisplayName, item.UninstallString)) | |||
{ | |||
item.RunUninstaller(false, Settings.Default.AdvancedSimulate).WaitForExit(60000); | |||
item?.RunUninstaller(false, Settings.Default.AdvancedSimulate).WaitForExit(60000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the check added this will throw a nullreference in the next line instead.
@@ -30,7 +30,7 @@ public override void Render(Graphics g, Rectangle r) | |||
r = ApplyCellPadding(r); | |||
|
|||
// Convert our aspect to a numeric value | |||
var aspect = (RatingEntry) Aspect; | |||
var aspect = (RatingEntry) (Aspect ?? false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will throw an invalid cast exception.
@@ -43,7 +43,7 @@ public override void Render(Graphics g, Rectangle r) | |||
// Calculate how many images we need to draw to represent our aspect value | |||
int numberOfImages; | |||
if (aspectValue <= _minimumValue) numberOfImages = 1; | |||
else if (aspectValue <= (_maximumValue + _minimumValue)/2) numberOfImages = 2; | |||
else if (aspectValue <= (float) (_maximumValue + _minimumValue) / 2) numberOfImages = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the clamping is intentional.
@@ -48,7 +48,7 @@ private void SearcherOnHoveredWindowChanged(object sender, WindowHoverEventArgs | |||
{ | |||
label1.Text = windowHoverEventArgs.TargetWindow.WindowText; | |||
label2.Text = windowHoverEventArgs.TargetWindow.WindowRect.ToString(); | |||
label3.Text = windowHoverEventArgs.TargetWindow.GetRunningProcess().MainModule.FileName; | |||
label3.Text = windowHoverEventArgs.TargetWindow?.GetRunningProcess().MainModule.FileName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can never be null.
info = this.ListView.OlvHitTest(pt.X, pt.Y - SMALL_VALUE); | ||
if (info.Item != null) { | ||
targetIndex = info.Item.Index; | ||
if (info.Item != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should never be null.
@@ -193,7 +193,7 @@ private void RefreshSelectedFilter() | |||
var item = listView1.SelectedItems[0]; | |||
var tag = CurrentlySelected; | |||
|
|||
item.SubItems[0].Text = tag.Name; | |||
item.SubItems[0].Text = tag?.Name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the check added this will throw a nullreference below instead.
@@ -128,7 +128,7 @@ IEnumerable<DirectoryInfo> FindDirsOnDrive(DriveInfo d) | |||
{ | |||
try | |||
{ | |||
return x.GetDirectories(); | |||
return x?.GetDirectories(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can never be null.
@@ -14,7 +14,7 @@ public void AddMissingInformation(ApplicationUninstallerEntry target) | |||
{ | |||
if (target.UninstallerKind != UninstallerType.Steam || !SteamFactory.SteamHelperIsAvailable) return; | |||
|
|||
var appId = target.RatingId.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Last(); | |||
var appId = target?.RatingId.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Last(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can never be null.
@@ -80,7 +80,7 @@ private static void ApplyMsiInfo(ApplicationUninstallerEntry entry, Guid guid) | |||
if (!temp.IsNotEmpty()) return; | |||
try | |||
{ | |||
entry.InstallDate = new DateTime(int.Parse(temp.Substring(0, 4)), | |||
entry.InstallDate = new DateTime(int.Parse(temp?.Substring(0, 4)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can never be null.
I added fixes to confirmed issues in separate commits, so I'll be closing the PR now. Thank you for finding these. |
@Klocman, ok. Thx for contribution! |
@Klocman, review pr code changes and feedback me.