diff options
author | Vsevolod Kukol <sevoku@microsoft.com> | 2019-07-18 16:42:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-18 16:42:33 +0300 |
commit | ea457b69f4d4e387cc08ae403ef3d0ebf00debad (patch) | |
tree | 3d486d2fefadb5e8f2f842241d4e6bf0b4270ddd /main | |
parent | 27ef12c32950e2a9618e9a3c6c65bab94cf183b5 (diff) | |
parent | 091d8c8cdfd044f4f41543e5dc43dc382f5250ad (diff) |
Merge pull request #8213 from mono/fix905844-proper-bundle-icon-access
[Mac] Fix NSImageCacheException exception when getting the app icon
Diffstat (limited to 'main')
-rw-r--r-- | main/src/addins/MacPlatform/Dialogs/MacAlertDialogHandler.cs | 2 | ||||
-rw-r--r-- | main/src/addins/MacPlatform/MacPlatform.cs | 18 | ||||
-rw-r--r-- | main/src/addins/MacPlatform/MacProxyCredentialProvider.cs | 2 |
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 add27baa1b..7666fd55a7 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 3c40768954..49cadaa103 100644 --- a/main/src/addins/MacPlatform/MacPlatform.cs +++ b/main/src/addins/MacPlatform/MacPlatform.cs @@ -765,6 +765,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; @@ -792,7 +808,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)); |