[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: SWT and UI Thread block
|
- From: Mark Ingerman <mingerman@xxxxxxxxxxxxx>
- Date: Fri, 13 Jun 2008 09:47:08 -0400
- Newsgroups: eclipse.platform.swt
- Organization: EclipseCorner
- Thread-index: AcjNW/jNsz8Zz1kZuEmPZNtMMCMXqw==
- Thread-topic: SWT and UI Thread block
- User-agent: Microsoft-Entourage/12.10.0.080409
I tried the loop. It seemed to make the problem (on the MAC at least)
worse. Yeah, definitely sloppy coding on my part not disposing the menu.
Thanks for catching it.
On 6/13/08 3:59 AM, in article g2t9dv$e3i$1@xxxxxxxxxxxxxxxxx, "Tom Schindl"
<tom.schindl@xxxxxxxxxxxxxxx> wrote:
> Mark Ingerman schrieb:
>> I have a problem where I want the current UI execution to stop, and perform
>> some other ui (not a dialog box), and wait until that task is finished
>> before returning to the previous spot.
>>
>> I have code that is running inside GEF that wants to put up a menu when the
>> end connection (mouse down) event is run. I tried the following trick; it
>> works on the MAC and under windows, but not under Linux. I wonder if there
>> is a better way.
>>
>> Here is the code:
>>
>> do some code....
>>
>> Control c = Display.getCurrent().getFocusControl();
>> if (c != null) {
>> Menu old = c.getMenu();
>> MenuManager mm = new MenuManager();
>> for (String s : cats) {
>>
>> mm.add(new _Action(s, isSource));
>>
>> }
>>
>> final Menu m = mm.createContextMenu(c);
>> c.setMenu(m);
>> m.setVisible(true);
>> c.getDisplay().readAndDispatch();
>
> I could be completely wrong but this has to be a while loop checking if
> the menu is not disposed and call read and dispatch.
>
> display = c.getDisplay();
> while (!m.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
>
> One more note I think you are leaking a menu/menu-item with the current
> code because your are not disposing of the menu but only nulling it.
>
> Tom
--
Mark M. Ingerman
Senior Architect
Metatomix
www.metatomix.com
781 907-6746