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:
authorVsevolod Kukol <sevoku@microsoft.com>2019-07-16 19:32:03 +0300
committerVsevolod Kukol <sevoku@microsoft.com>2019-07-16 19:32:03 +0300
commit797d609b0f2cbdbe325a115693c0256bd71944ed (patch)
tree3fa6280567edd823319a63e8399cbfde9f266baa /main
parent560a020231b345761fadfa63f99ddd8a64d6c1ad (diff)
[Mac] Fix NSImageCacheException exception when getting the app icon
SharedApplication.ApplicationIconImage is not meant to be used to retrieve the actual bundle icon, but only to change the default icon. Instead of SharedApplication.ApplicationIconImage get the icon directly from the bundle by default and fall-back to BrandingService if not running from an app bundle. Fixes VSTS #905844
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 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..705df36dd6 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;
+ }
+ set {
+ 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);
+ NSApplication.SharedApplication.ApplicationIconImage = 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));