Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Cocoa SWT_AWT issues, and a new API proposal

On Sep 21, 2009, at 11:17 AM, Silenio Quarti wrote:

> > On Sep 21, 2009, at 7:22 AM, Silenio Quarti wrote:
> >
> > > I believe that detecting if  TransformProcessType()needs be called
> > > should be done as this bug describes.
> > >
> > > https://bugs.eclipse.org/bugs/show_bug.cgi?id=268687
> >
> > I agree, though that's a separate problem from what I was running  
> into
> > here.  In this case, we weren't calling TransformProcessType()  
> because
> > NSApplication.isRunning() returned true, but the AWT did not call it
> > either because it detected that the app was started from thread  
> 0.  I
> > wrote AWT startup to do the bare minimum if -XstartOnFirstThread was
> > detected on the assumption that the SWT would be used.
> >
>
> I agree it is a different problem, but it would fix your problem as  
> well. We would not check if the application is running. We would  
> just check if the application was bundled in order to decide if TPT  
> should be called.
>
> > I can work on detecting whether or not TPT should be called, though.
> > I had to make a similar change to the Carbon SWT for Flash  
> Catalyst to
> > work around a related problem.
>
> Is the way I describe on the bug (check to executable path) similar  
> to what you did? If so, I will finish up the outstanding changes I  
> have in my workspace.

In Carbon I check to see if I get a bundle (CFBundleGetMainBundle())  
and then call CFBundleGetIdentifier.  If it returns null the  
application is not bundled.  I _believe_ this works whether you run  
from the command line or double-click.

In the command line case, you may get a bundle if the app was launched  
with /usr/bin/java as opposed to an explicit Java path (/System/ 
Library/Frameworks/JavaVM.framework..../java) but in that case I think  
you could check to see what string you got back and make sure it isn't  
the known Java bundle identifier.

> >
> > > As for documenting the rules, we can add something on the SWT  
> FAQ or
> > > to the java doc of SWT_AWT.java. It seems that we should not  
> support
> > > the case where the app is started without the -XstartOnFirstThread
> > > option.
> >
> > Can you clarify a bit?  SWT_AWT should not support it or Display
> > should not support being created off the main thread?
> >
>
> I believe we cannot support either. Java has to be started with - 
> XstartOnFirstThread and the Display has to be created in the main  
> thread. SWT_AWT.new_shell() has the same restriction.

Right... I can add a check to Display.createDisplay() that throws an  
error if NSThread.isMainThread() returns false.  That should be  
sufficient, because you can't call SWT_AWT.new_Shell() if display  
creation fails.

-- Scott


Back to the top