Community
Participate
Working Groups
Build Identifier: SWT 3.5.2 Today a got a stack trace from one of our dev clients. I don't believe they did something special... maybe they changed the system font. Reproducible: Didn't try
Sorry, I forgot the stack trace. Here is it: java.lang.NullPointerException at org.eclipse.swt.widgets.Control.updateFont(Unknown Source) at org.eclipse.swt.widgets.Composite.updateFont(Unknown Source) at org.eclipse.swt.widgets.Composite.updateFont(Unknown Source) at org.eclipse.swt.widgets.Composite.updateFont(Unknown Source) at org.eclipse.swt.widgets.Composite.updateFont(Unknown Source) at org.eclipse.swt.widgets.Composite.updateFont(Unknown Source) at org.eclipse.swt.widgets.Display.runSettings(Unknown Source) at org.eclipse.swt.widgets.Display.messageProc(Unknown Source) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(Unknown Source) at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source) at de.ikoffice.gui.MainWindow.open(MainWindow.java:1274) at de.ikoffice.client.IKOfficeClient.run(IKOfficeClient.java:213) at java.lang.Thread.run(Unknown Source)
Just got the following info: The bug occured while the user was changing the desktop background. I believe this sends some update message to all processes, and SWT has some problems in their handling.
The function is this: void updateFont (Font oldFont, Font newFont) { if (getFont ().equals (oldFont)) setFont (newFont); } Obviously, if getFont() returns null, this will result in a null pointer exception. Please add an additional check here!
(In reply to comment #3) > The function is this: > void updateFont (Font oldFont, Font newFont) { > if (getFont ().equals (oldFont)) setFont (newFont); > } > Obviously, if getFont() returns null, this will result in a null pointer > exception. Please add an additional check here! This is not correct, getFont() should not return null. Putting a check to this one method will fix the case you are running into, but all other callers of getFont() will still have the bug. Does the problem happen to 3.7 ? (we are not fixing bugs in 3.5.x any more) What control is the problem happening to ? (a Text, a Button, etc) Do you have a reproducible test case ? - Can you attach it here ? If not, can you debug the problem and find out why getFont() is returning NULL ? Thank you.
Sorry, it was my fault. It was a custom component that had its own getFont() and setFont() functions. I didn't know they always have to return a non-null value, and thought null ~ some default font. Thanks for your time anyway. Regards, Daniel Migowski