Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 353019 - Change display.getDefault() javadoc
Summary: Change display.getDefault() javadoc
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-25 11:44 EDT by Wim Jongman CLA
Modified: 2011-08-15 14:31 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wim Jongman CLA 2011-07-25 11:44:38 EDT
In reaction to bug 352992 I request to change the javadoc of Display.getDefault() to something like:

/**
 * Returns the default display. One is created (making the thread that
 * invokes this method its user-interface thread) if it did not already
 * exist.
 * <p/>
 * Calling this method should be avoided. Instead, get the display from the
 * parent widget by calling {@link Widget#getDisplay()}. Inside the Eclipse
 * Workbench the method <code>IWorkbench.getDisplay()</code> must be called
 * instead of this method.
 * 
 * @return the default display
 */
Comment 1 Felipe Heidrich CLA 2011-07-26 12:36:29 EDT
why should Display.getDefault() be avoid ?
Comment 2 Wim Jongman CLA 2011-07-26 12:45:37 EDT
(In reply to comment #1)
> why should Display.getDefault() be avoid ?

Because it is not guaranteed to return the Display that runs the user interface.
Comment 3 Wim Jongman CLA 2011-07-26 12:47:24 EDT
(In reply to comment #2)
> (In reply to comment #1)
> > why should Display.getDefault() be avoid ?
> 
> Because it is not guaranteed to return the Display that runs the user
> interface.

Well.. What I wanted to point out that in case of Eclipse, the Workbench.getdisplay() method is the only save way to get the Display. I know SWT can be run sep from Eclipse but in most cases it is not.
Comment 4 Paul Webster CLA 2011-07-26 13:00:10 EDT
As a consumer of SWT, the workbench has to set the policy for using or not use the display.

I feel that it's a workbench problem, not really SWT (unless they want to post an see also)

PW
Comment 5 Wim Jongman CLA 2011-07-27 06:19:40 EDT
(In reply to comment #4)
> As a consumer of SWT, the workbench has to set the policy for using or not use
> the display.
> 
> I feel that it's a workbench problem, not really SWT (unless they want to post
> an see also)
> 
> PW

Yes, I agree. SWT is not responsible for Workbench problems. However, since the two are so closely related. Maybe I am making a too big deal out of this.

It would be nice for SWT users to know that getting the display through the parent instead of through getDefault would make sure that the correct display is used inside and outside Eclipse.

It would also be nice for SWT users to know that IWorkbench.getdisplay() is the only valid way of getting the Workbench Display.

Maybe I should just write a blog about it so that people can find some comments to this odd behavior in the rare case they should encounter it.
Comment 6 Wim Jongman CLA 2011-08-15 14:31:18 EDT
We have a reference here and nobody seems alarmed enough to fix it so I'm closing as WONTFIX