Community
Participate
Working Groups
3.5, 3.6 and latest 3.7 build. Happens on MacOSX 10.5.6 and 10.5.8 but not 10.6. Our org.eclipse.jdt.ui.tests.leaks.JavaLeakTest.testJavaEditorContextMenu() test ('org.eclipse.jdt.ui.tests' bundle) waits forever on Mac Cocoa because the menu doesn't get closed using setVisible(false). The result is that the test runs 2 hours before it gets killed. This works on all other platforms and also on the latest Mac version, hence filing against SWT. The relevant code is in JavaLeakTest.openContextMenu(Menu). Should be easy to extract a snippet from that.
IMPORTANT NOTE: We disabled the test on Cocoa for now. To reproduce you need to remove the first two lines in JavaLeakTest.testJavaEditorContextMenu(). Lakshmi, you said you have access to a Mac with 10.5.x? If so, could you try to reproduce and create a small snippet? Thanks.
> but not 10.6. That's probably wrong. I initially ran the whole leak test suite via VNC on Cocoa/10.6, and it passed. Now I ran only JavaLeakTest.testJavaEditorContextMenu() and made sure I didn't touch the machine, and it looked like the menu also stayed up forever. Could be related to bug 246843. Maybe menu.setVisible(true) is also delayed here and the asyncExec that should hide the menu gets executed before the menu is even visible?
The snippet below prints ... menu.setVisible (true) menuShown menu.setVisible (false) ... and then shows the menu indefinitely on HEAD Cocoa on MacOS 10.6.4. Replacing the asyncExec(..) with display.timerExec(1000, ..) doesn't help. public class SnippetBug322253 { public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.open(); final Menu menu = new Menu(shell, SWT.POP_UP); menu.addMenuListener(new MenuListener() { public void menuShown(MenuEvent e) { System.out.println("menuShown"); } public void menuHidden(MenuEvent e) { System.out.println("menuHidden"); } }); MenuItem item = new MenuItem(menu, SWT.PUSH); item.setText("Menu Item"); while (!menu.isDisposed() && display.readAndDispatch()) { // loop, don't sleep } System.out.println("menu.setVisible (true)"); menu.setVisible(true); display.asyncExec(new Runnable() { public void run() { System.out.println("menu.setVisible (false)"); menu.setVisible(false); } }); while (!menu.isDisposed() && display.readAndDispatch()) { // loop, don't sleep } display.dispose(); } }
(In reply to comment #1) Hi Dani, I can reproduce this using the snippet in comment3 with both 10.5.8 and 10.6.3.
calling _setVisible(false) in Menu.setVisible fixes this. We call it in the other platforms, not sure why we are not calling it cocoa?
(In reply to comment #5) > calling _setVisible(false) in Menu.setVisible fixes this. We call it in the > other platforms, not sure why we are not calling it cocoa? I am not sure either. Looking at the history does not indicate any good reason. Please make the change.
Fixed in HEAD > 20100813.