Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Commit e6ab1b8

Browse files
Therzokmonojenkins
authored andcommitted
Always assign a CancellationTokenSource
1 parent d5e8667 commit e6ab1b8

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

main/src/addins/MacPlatform/Dialogs/MacOpenFileDialogHandler.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected override NSSavePanel OnCreatePanel (OpenFileDialogData data)
7272

7373
public bool Run (OpenFileDialogData data)
7474
{
75-
var panelClosedSource = MacSystemInformation.OsVersion < MacSystemInformation.Catalina ? new CancellationTokenSource () : null;
75+
using var panelClosedSource = new CancellationTokenSource ();
7676
try {
7777
using (var panel = CreatePanel (data, out var state)) {
7878
bool pathAlreadySet = false;
@@ -118,11 +118,11 @@ public bool Run (OpenFileDialogData data)
118118

119119
// TODO: support for data.CenterToParent, we could use sheeting.
120120
if (panel.RunModal () == 0 && !pathAlreadySet) {
121-
panelClosedSource?.Cancel ();
121+
panelClosedSource.Cancel ();
122122
IdeServices.DesktopService.FocusWindow (parent);
123123
return false;
124124
}
125-
panelClosedSource?.Cancel ();
125+
panelClosedSource.Cancel ();
126126
if (!pathAlreadySet)
127127
data.SelectedFiles = MacSelectFileDialogHandler.GetSelectedFiles (panel);
128128

@@ -140,8 +140,6 @@ public bool Run (OpenFileDialogData data)
140140
}
141141
} catch (Exception ex) {
142142
LoggingService.LogInternalError ("Error in Open File dialog", ex);
143-
} finally {
144-
panelClosedSource?.Dispose ();
145143
}
146144
return true;
147145
}

0 commit comments

Comments
 (0)