Skip to content

Commit 620b90c

Browse files
committed
null checks for TaskbarList
1 parent ba88233 commit 620b90c

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

FlashpointSecurePlayer/ProgressManager.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,8 @@ Rectangle prcClip
126126
[ComImport, Guid("56FDF344-FD6D-11D0-958A-006097C9A090"), ClassInterface(ClassInterfaceType.None)]
127127
private class TaskbarList { }
128128

129-
private static readonly ITaskbarList3 taskbarList = (ITaskbarList3)new TaskbarList();
130-
private static readonly bool taskbarListSupported = Environment.OSVersion.Version >= new Version(6, 1);
131-
private static bool taskbarListInitialized = false;
129+
private static ITaskbarList3 taskbarList = null;
130+
private static readonly bool taskbarListVersion = Environment.OSVersion.Version >= new Version(6, 1);
132131

133132
const int PROGRESS_FORM_VALUE_COMPLETE = 100;
134133

@@ -447,12 +446,15 @@ public static Form ProgressForm {
447446
return;
448447
}
449448

450-
if (taskbarListSupported && !taskbarListInitialized) {
451-
try {
452-
taskbarList.HrInit();
453-
taskbarListInitialized = true;
454-
} catch (Exception ex) {
455-
LogExceptionToLauncher(ex);
449+
if (taskbarList == null) {
450+
if (taskbarListVersion) {
451+
try {
452+
taskbarList = (ITaskbarList3)new TaskbarList();
453+
taskbarList.HrInit();
454+
} catch (Exception ex) {
455+
LogExceptionToLauncher(ex);
456+
taskbarList = null;
457+
}
456458
}
457459
}
458460

@@ -495,7 +497,7 @@ private static ProgressBarStyle ProgressFormStyle {
495497
return;
496498
}
497499

498-
if (!taskbarListInitialized) {
500+
if (taskbarList == null) {
499501
return;
500502
}
501503

@@ -541,7 +543,7 @@ private static int ProgressFormValue {
541543
return;
542544
}
543545

544-
if (!taskbarListInitialized) {
546+
if (taskbarList == null) {
545547
return;
546548
}
547549

@@ -611,7 +613,7 @@ private static IntPtr ProgressFormState {
611613
return;
612614
}
613615

614-
if (!taskbarListInitialized) {
616+
if (taskbarList == null) {
615617
return;
616618
}
617619

0 commit comments

Comments
 (0)