Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Display.getDefault() returns null
Display.getDefault() returns null [message #1415230] Tue, 02 September 2014 11:15 Go to next message
Mathias Dolag is currently offline Mathias DolagFriend
Messages: 6
Registered: September 2014
Junior Member
Hello,

referring to the following article and the API, the "Display.getDefault()" - call should always return a Display (even if it's not called from the UI-Thread): http://wiki.eclipse.org/FAQ_How_do_I_get_a_Display_instance%3F

In my RAP application I use a Job where I have to access some actions which further access widgets. Wrapping these calls with "Display.getDefault().asyncExec(...)" lead to a NullPointerException. I'm wondering why this unexpected behaviour occurs. Can someone explain this behaviour? Is it a bug or am I doing something wrong?

Regards,
Mathias
Re: Display.getDefault() returns null [message #1415262 is a reply to message #1415230] Tue, 02 September 2014 12:36 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2334
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Mathias,
RAP is multi user framework by its nature. Every user session is
associated with a display. In RAP, Display#getDefault() will not create
a new display when it's called from non-UI thread - read
Display#getDefault JavaDoc. When you execute a code in a background
thread, RAP needs to know for which UI session (display) it belongs.
That's why you have to provide the correct UISession/display from outside.
HTH,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Display.getDefault() returns null [message #1415282 is a reply to message #1415262] Tue, 02 September 2014 13:43 Go to previous messageGo to next message
Mathias Dolag is currently offline Mathias DolagFriend
Messages: 6
Registered: September 2014
Junior Member
Hi Ivan,

thanks for this explanation. Reading the API (http://download.eclipse.org/rt/rap/doc/2.3/guide/reference/api/org/eclipse/swt/widgets/Display.html#getDefault%28%29) I do not expect that a new Display is created, but that the Default Display of the user session is returned instead of "null". Maybe I missunderstand the API ... Providing the right display from outside is possible and an obvious solution and working fine.

Regards,
Mathias
Re: Display.getDefault() returns null [message #1415341 is a reply to message #1415282] Tue, 02 September 2014 15:01 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2334
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
in the background thread you are completely "blind" about the user
session (display). There is no such a thing like "default" user. In the
UI thread Display#getDefault will return the display associated with
this UI thread/session. That's why, you must supply the background
thread with correct display/UISession from outside.
Best,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:Rap ComboBox selection handling
Next Topic:Fixed Coolbar in SharedHeaderFormEditor?
Goto Forum:
  


Current Time: Mon Feb 24 12:04:38 GMT 2020

Powered by FUDForum. Page generated in 0.03055 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top