Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 417901

Summary: Text.setFont not being applied to text entered via Text.append if called via another thread.
Product: [Eclipse Project] Platform Reporter: Alex Clayton <alex.clayton>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P3 CC: lshanmug, Silenio_Quarti
Version: 4.3Keywords: triaged
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard: stalebug
Attachments:
Description Flags
Example Code to replicate/demonstrate the bug
none
Output from code when setFont is not called before call to append
none
Output from code when setFont is called before append. none

Description Alex Clayton CLA 2013-09-24 07:36:45 EDT
Created attachment 235746 [details]
Example Code to replicate/demonstrate the bug

Overview:

Running an SWT application on MAC OS X (Mountain Lion 10.8.5 (12F37))

I create an empty Text widget and set its font using the setFont() method. Then a worker/background thread calls Display.asynExec to append text to the Text widget via the append method.  The text appended does NOT have the selected font applied to it.

If however I set the font in the call to Display.asyncExec then the text does have the font applied.

Steps to reproduce:

1) Create a new SWT Text Widget.

...
output = new Text(
            shell,
            SWT.WRAP
              | SWT.MULTI
              | SWT.BORDER
              | SWT.H_SCROLL
              | SWT.V_SCROLL);
        GridData gridData =
          new GridData(SWT.FILL,SWT.FILL,true,true);
        output.setLayoutData(gridData);
        font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
        output.setFont(font);
...

2) In a Worker/Background thread call Display.asyncUpdate to append to text

... (in worker/backgournd thread)
display.asyncExec(new Runnable() { 
                @Override
                public void run() {
                   if (output != null && !output.isDisposed()) {
                       // Commented Out 
                       // font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
                       // output.setFont(font);
                       output.append(outputString); 
                   }  
                }
...

3) The text added to 'output' will not have the selected Font applied to it

4) If the commented out code is uncommented then the font is applied to all the text.

Actual Results:

The appended text does not have the font applied.

Expected Results:

The appended text should have the font applied.

Build Date & Hardware:

Build 2013-09-24 Mac OS X 10.8.5 (12F37)
SWT Version 4.3.32

Additional Builds and Platforms:

I've not seen this happen on other OSes.  Tested code on Fedora did not
see problem replicated there.

Additional Information:

Included example code to replicate the error, and screen shots showing output as attachments.
Comment 1 Alex Clayton CLA 2013-09-24 07:37:37 EDT
Created attachment 235747 [details]
Output from code when setFont is not called before call to append
Comment 2 Alex Clayton CLA 2013-09-24 07:38:07 EDT
Created attachment 235748 [details]
Output from code when setFont is called before append.
Comment 3 Lakshmi P Shanmugam CLA 2017-07-03 02:59:47 EDT
Bug triaged, visit https://wiki.eclipse.org/SWT/Devel/Triage for more
information.
Comment 4 Eclipse Genie CLA 2020-06-19 15:08:52 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.