View | Details | Raw Unified | Return to bug 269173
Collapse All | Expand All

(-)Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java (-12 / +50 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-19 Link Here
11
package org.eclipse.swt.widgets;
11
package org.eclipse.swt.widgets;
12
12
13
13
14
import org.eclipse.swt.internal.win32.*;
14
import java.lang.ref.WeakReference;
15
import org.eclipse.swt.*;
15
16
import org.eclipse.swt.graphics.*;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWTException;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.ImageData;
20
import org.eclipse.swt.graphics.Point;
21
import org.eclipse.swt.graphics.Rectangle;
22
import org.eclipse.swt.internal.win32.ACCEL;
23
import org.eclipse.swt.internal.win32.CREATESTRUCT;
24
import org.eclipse.swt.internal.win32.LRESULT;
25
import org.eclipse.swt.internal.win32.MENUITEMINFO;
26
import org.eclipse.swt.internal.win32.MSG;
27
import org.eclipse.swt.internal.win32.OS;
28
import org.eclipse.swt.internal.win32.RECT;
29
import org.eclipse.swt.internal.win32.STARTUPINFO;
30
import org.eclipse.swt.internal.win32.TCHAR;
31
import org.eclipse.swt.internal.win32.WINDOWPLACEMENT;
32
import org.eclipse.swt.internal.win32.WINDOWPOS;
17
33
18
/**
34
/**
19
 * Instances of this class provide the appearance and
35
 * Instances of this class provide the appearance and
Lines 96-105 Link Here
96
 */
112
 */
97
113
98
public class Decorations extends Canvas {
114
public class Decorations extends Canvas {
115
	
116
	private static class WeakMenuReference extends WeakReference {
117
		private Error error;
118
119
		public WeakMenuReference(Object r) {
120
			super(r);
121
			error = new Error();
122
		}
123
		
124
		public boolean enqueue() {
125
			System.err.println("Decorations.WeakMenuReference.enqueue(): " + get()); //$NON-NLS-1$
126
			error.printStackTrace();
127
			return super.enqueue();
128
		}
129
	}
130
	
99
	Image image, smallImage, largeImage;
131
	Image image, smallImage, largeImage;
100
	Image [] images;
132
	Image [] images;
101
	Menu menuBar;
133
	Menu menuBar;
102
	Menu [] menus;
134
	WeakMenuReference [] menus;
103
	Control savedFocus;
135
	Control savedFocus;
104
	Button defaultButton, saveDefault;
136
	Button defaultButton, saveDefault;
105
	int swFlags, nAccel;
137
	int swFlags, nAccel;
Lines 201-215 Link Here
201
}
233
}
202
234
203
void addMenu (Menu menu) {
235
void addMenu (Menu menu) {
204
	if (menus == null) menus = new Menu [4];
236
	if (menus == null) menus = new WeakMenuReference[4];
205
	for (int i=0; i<menus.length; i++) {
237
	for (int i=0; i<menus.length; i++) {
206
		if (menus [i] == null) {
238
		if (menus [i] == null) {
207
			menus [i] = menu;
239
			menus [i] = new WeakMenuReference(menu);
208
			return;
240
			return;
209
		}
241
		}
210
	}
242
	}
211
	Menu [] newMenus = new Menu [menus.length + 4];
243
	WeakMenuReference [] newMenus = new WeakMenuReference [menus.length + 4];
212
	newMenus [menus.length] = menu;
244
	newMenus [menus.length] = new WeakMenuReference(menu);
213
	System.arraycopy (menus, 0, newMenus, 0, menus.length);
245
	System.arraycopy (menus, 0, newMenus, 0, menus.length);
214
	menus = newMenus;
246
	menus = newMenus;
215
}
247
}
Lines 450-456 Link Here
450
Menu findMenu (int /*long*/ hMenu) {
482
Menu findMenu (int /*long*/ hMenu) {
451
	if (menus == null) return null;
483
	if (menus == null) return null;
452
	for (int i=0; i<menus.length; i++) {
484
	for (int i=0; i<menus.length; i++) {
453
		Menu menu = menus [i];
485
		WeakMenuReference weakMenuReference= menus [i];
486
		Menu menu = weakMenuReference == null ? null : (Menu) weakMenuReference.get();
454
		if (menu != null && hMenu == menu.handle) return menu;
487
		if (menu != null && hMenu == menu.handle) return menu;
455
	}
488
	}
456
	return null;
489
	return null;
Lines 772-779 Link Here
772
	super.releaseChildren (destroy);
805
	super.releaseChildren (destroy);
773
	if (menus != null) {
806
	if (menus != null) {
774
		for (int i=0; i<menus.length; i++) {
807
		for (int i=0; i<menus.length; i++) {
775
			Menu menu = menus [i];
808
			WeakMenuReference weakMenuReference= menus [i];
809
			Menu menu = weakMenuReference == null ? null : (Menu) weakMenuReference.get();
776
			if (menu != null && !menu.isDisposed ()) {
810
			if (menu != null && !menu.isDisposed ()) {
811
				System.err.println("Decorations releases menu: " + menu); //$NON-NLS-1$
812
				weakMenuReference.error.printStackTrace();
777
				menu.dispose ();
813
				menu.dispose ();
778
			}
814
			}
779
		}
815
		}
Lines 796-802 Link Here
796
void removeMenu (Menu menu) {
832
void removeMenu (Menu menu) {
797
	if (menus == null) return;
833
	if (menus == null) return;
798
	for (int i=0; i<menus.length; i++) {
834
	for (int i=0; i<menus.length; i++) {
799
		if (menus [i] == menu) {
835
		WeakMenuReference weakMenuReference= menus [i];
836
		Menu menu2 = weakMenuReference == null ? null : (Menu) weakMenuReference.get();
837
		if (menu2 == menu) {
800
			menus [i] = null;
838
			menus [i] = null;
801
			return;
839
			return;
802
		}
840
		}

Return to bug 269173