summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/cocoa
diff options
context:
space:
mode:
authorGrant Gayed <ggayed>2009-02-18 15:14:32 +0000
committerGrant Gayed <ggayed>2009-02-18 15:14:32 +0000
commit420ecc6978c2595bdf9b71ed40b757930d738678 (patch)
tree8950a003154af592ef0cba3a9e16254061c28bdf /bundles/org.eclipse.swt/Eclipse SWT/cocoa
parent0c265790d48c978702367475ec1c694c7aa98881 (diff)
downloadeclipse.platform.swt-420ecc6978c2595bdf9b71ed40b757930d738678.tar.gz
eclipse.platform.swt-420ecc6978c2595bdf9b71ed40b757930d738678.tar.xz
eclipse.platform.swt-420ecc6978c2595bdf9b71ed40b757930d738678.zip
264714 - drawing to Image can fail
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/cocoa')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TrayItem.java25
2 files changed, 37 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java
index ff127de99e..12929a35c0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java
@@ -481,6 +481,21 @@ public void setImage (Image image) {
}
this.image = image;
isImage = true;
+
+ /*
+ * Feature in Cocoa. If the NSImage object being set into the view is
+ * the same NSImage object that is already there then the new image is
+ * not taken. This results in the view's image not changing even if the
+ * NSImage object's content has changed since it was last set into the
+ * view. The workaround is to temporarily set the view's image to null
+ * so that the new image will then be taken.
+ */
+ if (image != null) {
+ NSImage current = imageView.image ();
+ if (current != null && current.id == image.handle.id) {
+ imageView.setImage (null);
+ }
+ }
imageView.setImage(image != null ? image.handle : null);
((NSBox)view).setContentView(imageView);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TrayItem.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TrayItem.java
index 4ae1b78543..0abaa17d49 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TrayItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TrayItem.java
@@ -337,9 +337,28 @@ public void setImage (Image image) {
checkWidget ();
if (image != null && image.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
super.setImage (image);
- view.setImage(image != null ? image.handle : null);
- float /*double*/ width = image != null && visible ? image.handle.size().width + BORDER : 0;
- item.setLength(width);
+ float /*double*/ width = 0;
+ if (image == null) {
+ view.setImage (null);
+ } else {
+ /*
+ * Feature in Cocoa. If the NSImage object being set into the view is
+ * the same NSImage object that is already there then the new image is
+ * not taken. This results in the view's image not changing even if the
+ * NSImage object's content has changed since it was last set into the
+ * view. The workaround is to temporarily set the view's image to null
+ * so that the new image will then be taken.
+ */
+ NSImage current = view.image ();
+ if (current != null && current.id == image.handle.id) {
+ view.setImage (null);
+ }
+ view.setImage (image.handle);
+ if (visible) {
+ width = image.handle.size ().width + BORDER;
+ }
+ }
+ item.setLength (width);
}
/**