diff options
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java | 19 | ||||
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java | 11 |
2 files changed, 29 insertions, 1 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java index a9a6b14a2a..44698389da 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java @@ -222,6 +222,9 @@ public class Display extends Device { /* Fonts */
byte [] TEXT_FONT, LIST_FONT;
+ /* Images */
+ int nullImage;
+
/* ScrollBars */
int SCROLLBAR_WIDTH;
int SCROLLBAR_HEIGHT;
@@ -845,6 +848,7 @@ protected void init () { initializeWidgetColors ();
initializeWidgetFonts ();
initializeScrollbars ();
+ initializeImages ();
}
void initializeDisplay () {
@@ -1037,6 +1041,11 @@ void initializeWidgetFonts () { OS.PtDestroyWidget (shellHandle);
}
+void initializeImages () {
+ nullImage = OS.PhCreateImage (null, (short) 1, (short) 1, OS.Pg_IMAGE_DIRECT_888, 0, 0, 0);
+ if (nullImage == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+}
+
int inputProc (int data, int rcvid, int message, int size) {
if (embedded) {
runDeferredEvents ();
@@ -1292,6 +1301,16 @@ void releaseDisplay () { inputCallback = null;
hotkeyCallback.dispose();
hotkeyCallback = null;
+
+ if (nullImage != 0) {
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, nullImage, PhImage_t.sizeof);
+ phImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(nullImage, phImage, PhImage_t.sizeof);
+ OS.PhReleaseImage(nullImage);
+ OS.free(nullImage);
+ nullImage = 0;
+ }
/* Release references */
thread = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java index 5ed55ced96..8426c909a8 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java @@ -603,7 +603,16 @@ public void setImage (Image image) { imageHandle = copyPhImage (image.handle);
if (text.length () != 0) type = OS.Pt_TEXT_IMAGE;
else type = OS.Pt_IMAGE;
- }
+ } else {
+ /*
+ * Bug in Photon. Photon will segment fault, if Pt_ARG_LABEL_IMAGE
+ * is set to NULL. This means that after setting an image into a
+ * PtMenuButton, it can never be removed. The fix is to set it to
+ * a small blank image.
+ */
+ Display display = getDisplay ();
+ imageHandle = copyPhImage (display.nullImage);
+ }
int [] args = {
OS.Pt_ARG_LABEL_IMAGE, imageHandle, 0,
OS.Pt_ARG_LABEL_TYPE, type, 0,
|