Awkward thing happens when I call shell.open() on a certain computer [message #498555] |
Tue, 17 November 2009 13:22 |
Alexandra Niculai Messages: 84 Registered: July 2009 |
Member |
|
|
Hi
I have created a class that extends Dialog. It also has a method in it, called public void open()
{
shell = new Shell(getParent(), getStyle());
shell.setText(getText());
// shell.setSize(315, 400);
importImages(shell);
createContents(shell);
if (bmImage != null) {
shell.setImage(bmImage);
}
shell.pack();
shell.open();
Display display = getParent().getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
So, when an event occurs, the program creates an object of this class and then calls the open() method on it. Everything goes well on my computer(Windows XP), on other computers with XP, also on Windows Vista and 7.
The problem is on this one specific computer. I've used logging to see exactly where the problem is and the program crashes when calling shell.open(). Here is the stack trace above shell.open():
null
isActive at line -1 in class org.eclipse.swt.widgets.Control
updateModal at line -1 in class org.eclipse.swt.widgets.Shell
setModalShell at line -1 in class org.eclipse.swt.widgets.Display
setVisible at line -1 in class org.eclipse.swt.widgets.Shell
open at line -1 in class org.eclipse.swt.widgets.Shell
open at line 81
Could anyone please help me understand what's happening? The computer with the problem is running on Windows XP, service pack 3 and has no problem opening other Dialogs, only this one.
[Updated on: Tue, 17 November 2009 13:23] Report message to a moderator
|
|
|
Re: Awkward thing happens when I call shell.open() on a certain computer [message #498588 is a reply to message #498555] |
Tue, 17 November 2009 15:08 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi,
You're saying there's a Null Pointer Exception happening in
Control.isActive(), right? Can you provide the stack trace that's being
dumped, to see which line has the problem? Otherwise it's difficult to know
why this would fail on one machine in particular. Does the machine have any
unusual Windows features/add-ons running that the others don't? Is it using
the Classic theme instead of the default XP theme?
Grant
"Alexandra Niculai" <alexa.sunshine@gmail.com> wrote in message
news:hdu82l$vgi$1@build.eclipse.org...
> Hi
>
> I have created a class that extends Dialog. It also has a method in it,
called public void open()
> {
> shell = new Shell(getParent(), getStyle());
> shell.setText(getText());
> // shell.setSize(315, 400);
> importImages(shell);
> createContents(shell);
> if (bmImage != null) {
> shell.setImage(bmImage);
> }
> shell.pack();
> shell.open();
> Display display = getParent().getDisplay();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> }
>
> So, when an event occurs, the program creates an object of this class and
then calls the open() method on it. Everything goes well on my
computer(Windows XP), on other computers with XP, also on Windows Vista and
7.
> The problem is on this one specific computer. I've used logging to see
exactly where the problem is and the program crashes when calling
shell.open(). Here is the stack trace above shell.open():
> null
> isActive at line -1 in class org.eclipse.swt.widgets.Control
> updateModal at line -1 in class org.eclipse.swt.widgets.Shell
> setModalShell at line -1 in class org.eclipse.swt.widgets.Display
> setVisible at line -1 in class org.eclipse.swt.widgets.Shell
> open at line -1 in class org.eclipse.swt.widgets.Shell
> open at line 81
>
> Could anyone help me understand what's happening? The computer with the
problem is running on Windows XP, service pack 3 and has no problem opening
other Dialogs, only this one.
|
|
|
|
|
|
|
|
Re: Awkward thing happens when I call shell.open() on a certain computer [message #501258 is a reply to message #500720] |
Tue, 01 December 2009 16:48 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
I've looked into this, and my guess is that somehow another shell is being
disposed during the process of opening the MessageBox (eg.- in a listener?).
However I don't see the problem on my machine, and I'm pretty sure there's
nothing in your snippet that should cause this to happen, so I think you
need to debug your app on the machine that's showing the problem. Try the
following:
- retrieve the two swt plugins into your workspace (eg.- File > Import... >
Plug-ins and Fragments > Projects with source folders > ...)
- put a breakpoint at the beginning of Display.setModalDialog()
- debug your app, trigger the bad condition, hit the breakpoint
-> look at the result of the getShells() call, are any of them disposed?
getShells() should not return any disposed Shells. Assuming not...
- now put a breakpoint at the beginning of Control.isActive(), which will be
hit when Shell.updateModal() is invoked for each of these Shells
-> is the receiver now disposed (but presumably was not before)? If so,
how did it get disposed? A disposed Shell should be the only time that a
Shell's display is null
Even having looked at swt's code in this area I was not able to change the
snippet to fail on my machine, so I don't think I can investigate further.
However feel free to follow up here with observations/questions that arise
from debugging on the problem machine.
Grant
"Alexandra Niculai" <alexa.sunshine@gmail.com> wrote in message
news:hep2l9$34a$1@build.eclipse.org...
> Thank you for replying! Here is the name of the swt jar I'm using:
> org.eclipse.win32.win32.x86_3.5.1.v555a.jar
> There is no style for the shell. And here is a snippet:
>
> package test;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.events.SelectionAdapter;
> import org.eclipse.swt.events.SelectionEvent;
> import org.eclipse.swt.graphics.Image;
> import org.eclipse.swt.layout.FormLayout;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.MessageBox;
> import org.eclipse.swt.widgets.Shell;
>
> public class Main {
>
> Image arrow;
> Image img;
>
> public static void main(String[] args) {
> Display display = new Display();
> final Shell myShell = new Shell(display);
>
> FormLayout formLayout = new FormLayout();
> myShell.setLayout(formLayout);
>
> Button button = new Button(myShell, SWT.PUSH);
> button.setText("Push");
>
> button.addSelectionListener(new SelectionAdapter() {
> @Override
> public void widgetSelected(SelectionEvent event) {
> MessageBox mb = new MessageBox(myShell, SWT.ICON_QUESTION
> | SWT.YES | SWT.NO | SWT.CANCEL);
> mb.setText("Question");
> mb.setMessage("Do you want to add a new operation?");
> int val = mb.open();// this is where it has a problem
> }
> });
>
> myShell.open();
> while (!myShell.isDisposed()) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> display.dispose();
> }
>
> }
>
>
> The problem is when trying to open the MessageBox dialog.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04117 seconds