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
path: root/main
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2019-07-26 16:43:19 +0300
committerGitHub <noreply@github.com>2019-07-26 16:43:19 +0300
commit08b3d90c71eabd57b8e7d9850508134fb73e0687 (patch)
tree5863fe4e48964dee040257154b39dc25c7795d17 /main
parentbb2a58a2ce0c343ebc84a473701c78a60f045864 (diff)
parentb264c6e7567563b400bd084f8e1910cabdf44eed (diff)
Merge pull request #8214 from mono/backport-pr-8213-to-release-8.2
[release-8.2] [Mac] Fix NSImageCacheException exception when getting the app icon
Diffstat (limited to 'main')
-rw-r--r--main/src/addins/MacPlatform/Dialogs/MacAlertDialogHandler.cs2
-rw-r--r--main/src/addins/MacPlatform/MacPlatform.cs18
-rw-r--r--main/src/addins/MacPlatform/MacProxyCredentialProvider.cs2
3 files changed, 19 insertions, 3 deletions
diff --git a/main/src/addins/MacPlatform/Dialogs/MacAlertDialogHandler.cs b/main/src/addins/MacPlatform/Dialogs/MacAlertDialogHandler.cs
index 05ce4d84fb..eaed84e665 100644
--- a/main/src/addins/MacPlatform/Dialogs/MacAlertDialogHandler.cs
+++ b/main/src/addins/MacPlatform/Dialogs/MacAlertDialogHandler.cs
@@ -73,7 +73,7 @@ namespace MonoDevelop.MacIntegration
alert.Icon = img.ToNSImage ();
} else {
//for some reason the NSAlert doesn't pick up the app icon by default
- alert.Icon = NSApplication.SharedApplication.ApplicationIconImage;
+ alert.Icon = MacPlatformService.ApplicationIcon;
}
alert.MessageText = data.Message.Text;
diff --git a/main/src/addins/MacPlatform/MacPlatform.cs b/main/src/addins/MacPlatform/MacPlatform.cs
index 34a34620e9..d723648c6b 100644
--- a/main/src/addins/MacPlatform/MacPlatform.cs
+++ b/main/src/addins/MacPlatform/MacPlatform.cs
@@ -763,6 +763,22 @@ namespace MonoDevelop.MacIntegration
[DllImport ("/usr/lib/libobjc.dylib", EntryPoint = "objc_msgSend")]
public extern static IntPtr IntPtr_objc_msgSend_IntPtr (IntPtr receiver, IntPtr selector, IntPtr arg1);
+ private static NSImage applicationIcon;
+ internal static NSImage ApplicationIcon {
+ get {
+ if (applicationIcon == null) {
+ // use the bundle icon by default
+ // if run from a bundle, this will be the icon from the bundle icon file.
+ // if not run from a bundle, this will be the default file icon of the mono framework folder.
+ applicationIcon = NSWorkspace.SharedWorkspace.IconForFile (NSBundle.MainBundle.BundlePath);
+ }
+ return applicationIcon;
+ }
+ private set {
+ NSApplication.SharedApplication.ApplicationIconImage = applicationIcon = value;
+ }
+ }
+
static void SetupDockIcon ()
{
NSObject initialBundleIconFileValue;
@@ -790,7 +806,7 @@ namespace MonoDevelop.MacIntegration
var imageFile = new NSString (iconFile);
IntPtr p = IntPtr_objc_msgSend_IntPtr (image.Handle, Selector.GetHandle ("initByReferencingFile:"), imageFile.Handle);
- NSApplication.SharedApplication.ApplicationIconImage = ObjCRuntime.Runtime.GetNSObject<NSImage> (p);
+ ApplicationIcon = ObjCRuntime.Runtime.GetNSObject<NSImage> (p);
}
}
diff --git a/main/src/addins/MacPlatform/MacProxyCredentialProvider.cs b/main/src/addins/MacPlatform/MacProxyCredentialProvider.cs
index 7b21f4fbae..423d92b043 100644
--- a/main/src/addins/MacPlatform/MacProxyCredentialProvider.cs
+++ b/main/src/addins/MacPlatform/MacProxyCredentialProvider.cs
@@ -122,7 +122,7 @@ namespace MonoDevelop.MacIntegration
var okButton = alert.AddButton (GettextCatalog.GetString ("OK"));
var cancelButton = alert.AddButton (GettextCatalog.GetString ("Cancel"));
- alert.Icon = NSApplication.SharedApplication.ApplicationIconImage;
+ alert.Icon = MacPlatformService.ApplicationIcon;
var view = new NSView (new CGRect (0, 0, 313, 91));