diff options
Diffstat (limited to 'main/src/addins/WindowsPlatform/WindowsPlatform.cs')
-rw-r--r-- | main/src/addins/WindowsPlatform/WindowsPlatform.cs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform.cs b/main/src/addins/WindowsPlatform/WindowsPlatform.cs index 6ff77f87d7..75b72d2f76 100644 --- a/main/src/addins/WindowsPlatform/WindowsPlatform.cs +++ b/main/src/addins/WindowsPlatform/WindowsPlatform.cs @@ -95,20 +95,25 @@ namespace MonoDevelop.Platform } Dictionary<string, Gdk.Pixbuf> icons = new Dictionary<string, Gdk.Pixbuf> (); - + + // http://msdn.microsoft.com/en-us/library/windows/desktop/bb762179(v=vs.85).aspx + // FIXME: You should call this function from a background thread. Failure to do so could cause the UI to stop responding. protected override Gdk.Pixbuf OnGetPixbufForFile (string filename, Gtk.IconSize size) { SHFILEINFO shinfo = new SHFILEINFO(); - Win32.SHGetFileInfo (filename, 0, ref shinfo, (uint) Marshal.SizeOf (shinfo), Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON | Win32.SHGFI_ICONLOCATION | Win32.SHGFI_TYPENAME); - if (shinfo.iIcon == IntPtr.Zero) - return null; - string key = shinfo.iIcon.ToString () + " - " + shinfo.szDisplayName; + Win32.SHGetFileInfoW (filename, Win32.FILE_ATTRIBUTES_NORMAL, ref shinfo, (uint)Marshal.SizeOf (shinfo), Win32.SHGFI_USEFILEATTRIBUTES | Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON | Win32.SHGFI_ICONLOCATION | Win32.SHGFI_TYPENAME);
+ if (shinfo.iIcon == 0) {
+ Win32.DestroyIcon (shinfo.hIcon);
+ return null;
+ } + string key = shinfo.iIcon + " - " + shinfo.szDisplayName; Gdk.Pixbuf pix; if (!icons.TryGetValue (key, out pix)) { var icon = Icon.FromHandle (shinfo.hIcon); pix = CreateFromResource (icon.ToBitmap ()); icons[key] = pix; - } + }
+ Win32.DestroyIcon (shinfo.hIcon); return pix; } |