Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVsevolod Kukol <sevoku@microsoft.com>2019-04-11 17:17:12 +0300
committerGitHub <noreply@github.com>2019-04-11 17:17:12 +0300
commit827fae2bcd4c5972aefef301a49f761d4078741d (patch)
tree7f35d0c3ee64d355762b5634029e56a7b3c133bf
parent4441acaf285551860975b3003ac71d269c7851ef (diff)
parenta13ef95a318891e050ff8e745783665b2444d6fd (diff)
Merge pull request #562 from xamarin/backport-pr-561-to-release-8.0
[release-8.0] [Mac] Fix leaking Proxy Credential Dialog
-rw-r--r--main/src/addins/MacPlatform/MacProxyCredentialProvider.cs104
1 files changed, 54 insertions, 50 deletions
diff --git a/main/src/addins/MacPlatform/MacProxyCredentialProvider.cs b/main/src/addins/MacPlatform/MacProxyCredentialProvider.cs
index ad74568afa..7b21f4fbae 100644
--- a/main/src/addins/MacPlatform/MacProxyCredentialProvider.cs
+++ b/main/src/addins/MacPlatform/MacProxyCredentialProvider.cs
@@ -115,56 +115,60 @@ namespace MonoDevelop.MacIntegration
uri.Host
);
- var alert = new NSAlert {
- MessageText = GettextCatalog.GetString ("Credentials Required"),
- InformativeText = message
- };
-
- var okButton = alert.AddButton (GettextCatalog.GetString ("OK"));
- var cancelButton = alert.AddButton (GettextCatalog.GetString ("Cancel"));
-
- alert.Icon = NSApplication.SharedApplication.ApplicationIconImage;
-
- var view = new NSView (new CGRect (0, 0, 313, 91));
-
- var usernameLabel = new NSTextField (new CGRect (17, 55, 71, 17)) {
- Identifier = "usernameLabel",
- StringValue = "Username:",
- Alignment = NSTextAlignment.Right,
- Editable = false,
- Bordered = false,
- DrawsBackground = false,
- Bezeled = false,
- Selectable = false,
- };
- view.AddSubview (usernameLabel);
-
- var usernameInput = new NSTextField (new CGRect (93, 52, 200, 22));
- view.AddSubview (usernameInput);
-
- var passwordLabel = new NSTextField (new CGRect (22, 23, 66, 17)) {
- StringValue = "Password:",
- Alignment = NSTextAlignment.Right,
- Editable = false,
- Bordered = false,
- DrawsBackground = false,
- Bezeled = false,
- Selectable = false,
- };
- view.AddSubview (passwordLabel);
-
- var passwordInput = new NSSecureTextField (new CGRect (93, 20, 200, 22));
- view.AddSubview (passwordInput);
-
- alert.AccessoryView = view;
- alert.Window.WeakDelegate = new PasswordAlertWindowDelegate (usernameInput, passwordInput, cancelButton, okButton);
- alert.Window.InitialFirstResponder = usernameInput;
- if (alert.RunModal () != NSAlertFirstButtonReturn)
- return;
-
- var username = usernameInput.StringValue;
- var password = passwordInput.StringValue;
- result = new NetworkCredential (username, password);
+ using (var alert = new NSAlert ()) {
+ alert.MessageText = GettextCatalog.GetString ("Credentials Required");
+ alert.InformativeText = message;
+
+ var okButton = alert.AddButton (GettextCatalog.GetString ("OK"));
+ var cancelButton = alert.AddButton (GettextCatalog.GetString ("Cancel"));
+
+ alert.Icon = NSApplication.SharedApplication.ApplicationIconImage;
+
+ var view = new NSView (new CGRect (0, 0, 313, 91));
+
+ var usernameLabel = new NSTextField (new CGRect (17, 55, 71, 17)) {
+ Identifier = "usernameLabel",
+ StringValue = "Username:",
+ Alignment = NSTextAlignment.Right,
+ Editable = false,
+ Bordered = false,
+ DrawsBackground = false,
+ Bezeled = false,
+ Selectable = false,
+ };
+ view.AddSubview (usernameLabel);
+
+ var usernameInput = new NSTextField (new CGRect (93, 52, 200, 22));
+ view.AddSubview (usernameInput);
+
+ var passwordLabel = new NSTextField (new CGRect (22, 23, 66, 17)) {
+ StringValue = "Password:",
+ Alignment = NSTextAlignment.Right,
+ Editable = false,
+ Bordered = false,
+ DrawsBackground = false,
+ Bezeled = false,
+ Selectable = false,
+ };
+ view.AddSubview (passwordLabel);
+
+ var passwordInput = new NSSecureTextField (new CGRect (93, 20, 200, 22));
+ view.AddSubview (passwordInput);
+
+ using (var alertDelegate = new PasswordAlertWindowDelegate (usernameInput, passwordInput, cancelButton, okButton)) {
+ alert.AccessoryView = view;
+ MonoDevelop.Components.IdeTheme.ApplyTheme (alert.Window);
+ alert.Window.WeakDelegate = alertDelegate;
+ alert.Window.InitialFirstResponder = usernameInput;
+ alert.Window.ReleasedWhenClosed = true;
+ if (alert.RunModal () == NSAlertFirstButtonReturn) {
+ var username = usernameInput.StringValue;
+ var password = passwordInput.StringValue;
+ result = new NetworkCredential (username, password);
+ }
+ alert.Window.Close ();
+ }
+ }
}
}).Wait ();