Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Invalid thread access
Invalid thread access [message #33141] Wed, 25 April 2007 06:34 Go to next message
Eclipse UserFriend
Originally posted by: swetha.yahoo.co.in

Hi,

I am developing a Gallery View using nebula gallery widget,
the createPartControl method is,

public void createPartControl(Composite parent)
{

gallery = new Gallery(parent, SWT.V_SCROLL);
);
noGroupRenderer = new NoGroupRenderer();
defaultGalleryItemRenderer = new DefaultGalleryItemRenderer();

(some other code)---------
------
-----------

}

the error is coming at the line
defaultGalleryItemRenderer = new DefaultGalleryItemRenderer();

in DefaultGalleryItemRenderer class the error is at the line,
foregroundColor =
Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUN D);

public DefaultGalleryItemRenderer() {
foregroundColor =
Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUN D);
backgroundColor =
Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUN D);
selectionForegroundColor = foregroundColor;
selectionBackgroundColor =
Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION );

// Create drop shadows
createColors();
}


The error is,

org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:3374)
at org.eclipse.swt.SWT.error(SWT.java:3297)
at org.eclipse.swt.SWT.error(SWT.java:3268)
at org.eclipse.swt.widgets.Display.error(Display.java:978)
at org.eclipse.swt.widgets.Display.checkDevice(Display.java:638 )
at org.eclipse.swt.widgets.Display.getSystemColor(Display.java: 1931)
at
org.eclipse.nebula.widgets.gallery.DefaultGalleryItemRendere r. <init>(DefaultGalleryItemRenderer.java:63)
at
com.sequenom.everest.ui.project.GalleryView.createPartContro l(GalleryView.java:335)
at
org.eclipse.ui.internal.ViewReference.createPartHelper(ViewR eference.java:332)
at org.eclipse.ui.internal.ViewReference.createPart(ViewReferen ce.java:197)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:566)
at
org.eclipse.ui.internal.WorkbenchPage$ActivationList.setActi ve(WorkbenchPage.java:3915)
at
org.eclipse.ui.internal.WorkbenchPage.restoreState(Workbench Page.java:2929)
at
org.eclipse.ui.internal.WorkbenchWindow.restoreState(Workben chWindow.java:1936)
at org.eclipse.ui.internal.Workbench.doRestoreState(Workbench.j ava:2857)
at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1665)
at org.eclipse.ui.internal.Workbench.access$12(Workbench.java:1 650)
at org.eclipse.ui.internal.Workbench$17.run(Workbench.java:1529 )
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1473)
at
org.eclipse.ui.internal.WorkbenchConfigurer.restoreState(Wor kbenchConfigur


Please help me in this,

Thanks in advance,
Swetha
Re: Invalid thread access [message #33176 is a reply to message #33141] Wed, 25 April 2007 07:40 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Well the root cause see seems to be that your createPartControl isn't
executed in the GUI-Thread or better said something is calling
createPartControl() in another thread than the GUI is running in. Could
you try simply calling:

public void createPartControl(Composite parent) {
Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUN D);
}

If this also produces an exception please log a bug against platform-ui.
The nebula-code is not the culprit here I think although I have only
looked at the parts you presented here.

Tom

Swetha schrieb:
> Hi,
>
> I am developing a Gallery View using nebula gallery widget,
> the createPartControl method is,
>
> public void createPartControl(Composite parent)
> {
>
> gallery = new Gallery(parent, SWT.V_SCROLL);
> );
> noGroupRenderer = new NoGroupRenderer();
> defaultGalleryItemRenderer = new DefaultGalleryItemRenderer();
>
> (some other code)---------
> ------
> -----------
> }
>
> the error is coming at the line defaultGalleryItemRenderer = new
> DefaultGalleryItemRenderer();
>
> in DefaultGalleryItemRenderer class the error is at the line,
> foregroundColor =
> Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUN D);
>
> public DefaultGalleryItemRenderer() {
> foregroundColor =
> Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUN D);
> backgroundColor =
> Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUN D);
> selectionForegroundColor = foregroundColor;
> selectionBackgroundColor =
> Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION );
>
> // Create drop shadows
> createColors();
> }
>
>
> The error is,
>
> org.eclipse.swt.SWTException: Invalid thread access
> at org.eclipse.swt.SWT.error(SWT.java:3374)
> at org.eclipse.swt.SWT.error(SWT.java:3297)
> at org.eclipse.swt.SWT.error(SWT.java:3268)
> at org.eclipse.swt.widgets.Display.error(Display.java:978)
> at org.eclipse.swt.widgets.Display.checkDevice(Display.java:638 )
> at org.eclipse.swt.widgets.Display.getSystemColor(Display.java: 1931)
> at
> org.eclipse.nebula.widgets.gallery.DefaultGalleryItemRendere r. <init>(DefaultGalleryItemRenderer.java:63)
>
> at
> com.sequenom.everest.ui.project.GalleryView.createPartContro l(GalleryView.java:335)
>
> at
> org.eclipse.ui.internal.ViewReference.createPartHelper(ViewR eference.java:332)
>
> at org.eclipse.ui.internal.ViewReference.createPart(ViewReferen ce.java:197)
> at
> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:566)
>
> at
> org.eclipse.ui.internal.WorkbenchPage$ActivationList.setActi ve(WorkbenchPage.java:3915)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.restoreState(Workbench Page.java:2929)
> at
> org.eclipse.ui.internal.WorkbenchWindow.restoreState(Workben chWindow.java:1936)
>
> at org.eclipse.ui.internal.Workbench.doRestoreState(Workbench.j ava:2857)
> at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1665)
> at org.eclipse.ui.internal.Workbench.access$12(Workbench.java:1 650)
> at org.eclipse.ui.internal.Workbench$17.run(Workbench.java:1529 )
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
> at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1473)
> at
> org.eclipse.ui.internal.WorkbenchConfigurer.restoreState(Wor kbenchConfigur
>
>
> Please help me in this,
>
> Thanks in advance,
> Swetha
>
>
>
Re: Invalid thread access [message #33211 is a reply to message #33176] Wed, 25 April 2007 08:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: swetha.yahoo.co.in

Hi,

That didn't work.. Before it used to run perfectly.. Suddenly the
error is coming..

Thanks,
Swetha
Re: Invalid thread access [message #33241 is a reply to message #33211] Wed, 25 April 2007 09:46 Go to previous messageGo to next message
Nicolas Richeton is currently offline Nicolas RichetonFriend
Messages: 179
Registered: July 2009
Senior Member
Hi,

It's true that the createPart code should be run for the swt thread. I
think you should check your code that is calling this view, because the
problem should be fixed there.

But if you want fix it here, try something like this :

public void createPartControl(Composite parent)
{
Display.getDefault().syncExec( new Runnable() {

void run( ) {
gallery = new Gallery(parent, SWT.V_SCROLL);
noGroupRenderer = new NoGroupRenderer();
defaultGalleryItemRenderer = new
DefaultGalleryItemRenderer();
}
}


}

--
Nicolas

Swetha a écrit :
> Hi,
>
> That didn't work.. Before it used to run perfectly.. Suddenly the
> error is coming..
>
> Thanks,
> Swetha
>
Re: Invalid thread access [message #33276 is a reply to message #33211] Wed, 25 April 2007 09:52 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

I consider this a bug in the Eclipse-Platform and file a bug against it.
It's really a major bug if eclipse is calling createPartControl() out of
the GUI-Thread and many other plugins will fail miserably. So please log
a bug against platform-ui and provide a step to step instruction how to
make this happen!

The work-around from Nicolas will put you on the safe side but please
once more LOG A BUG!

Did you see this behaviour with 3.3M6 or one of the latest I-builds?

Tom

Swetha schrieb:
> Hi,
>
> That didn't work.. Before it used to run perfectly.. Suddenly the
> error is coming..
>
> Thanks,
> Swetha
>
Re: Invalid thread access [message #33311 is a reply to message #33276] Wed, 25 April 2007 10:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: swetha.yahoo.co.in

Hi,

This error is gone.. donno the reason.. I just copied my project in new
workspace and I opened that workspace and run .. working as usual...

In fact my friend also faced the same problem once.. he told to do like
this.. and this is working.. what could be the reason..

Thanks,
Swetha
Re: Invalid thread access [message #33346 is a reply to message #33311] Wed, 25 April 2007 10:55 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

It seems the eclipse is starting a thread when starting up (because of
what ever reason but they forgot to sync the calls with to create part).
Please log a bug against Platform-UI attaching your stacktrace.

Tom

Swetha schrieb:
> Hi,
>
> This error is gone.. donno the reason.. I just copied my project in new
> workspace and I opened that workspace and run .. working as usual...
>
> In fact my friend also faced the same problem once.. he told to do like
> this.. and this is working.. what could be the reason..
>
> Thanks,
> Swetha
>
>
>
Re: Invalid thread access [message #581120 is a reply to message #33141] Wed, 25 April 2007 07:40 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Well the root cause see seems to be that your createPartControl isn't
executed in the GUI-Thread or better said something is calling
createPartControl() in another thread than the GUI is running in. Could
you try simply calling:

public void createPartControl(Composite parent) {
Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUN D);
}

If this also produces an exception please log a bug against platform-ui.
The nebula-code is not the culprit here I think although I have only
looked at the parts you presented here.

Tom

Swetha schrieb:
> Hi,
>
> I am developing a Gallery View using nebula gallery widget,
> the createPartControl method is,
>
> public void createPartControl(Composite parent)
> {
>
> gallery = new Gallery(parent, SWT.V_SCROLL);
> );
> noGroupRenderer = new NoGroupRenderer();
> defaultGalleryItemRenderer = new DefaultGalleryItemRenderer();
>
> (some other code)---------
> ------
> -----------
> }
>
> the error is coming at the line defaultGalleryItemRenderer = new
> DefaultGalleryItemRenderer();
>
> in DefaultGalleryItemRenderer class the error is at the line,
> foregroundColor =
> Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUN D);
>
> public DefaultGalleryItemRenderer() {
> foregroundColor =
> Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUN D);
> backgroundColor =
> Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUN D);
> selectionForegroundColor = foregroundColor;
> selectionBackgroundColor =
> Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION );
>
> // Create drop shadows
> createColors();
> }
>
>
> The error is,
>
> org.eclipse.swt.SWTException: Invalid thread access
> at org.eclipse.swt.SWT.error(SWT.java:3374)
> at org.eclipse.swt.SWT.error(SWT.java:3297)
> at org.eclipse.swt.SWT.error(SWT.java:3268)
> at org.eclipse.swt.widgets.Display.error(Display.java:978)
> at org.eclipse.swt.widgets.Display.checkDevice(Display.java:638 )
> at org.eclipse.swt.widgets.Display.getSystemColor(Display.java: 1931)
> at
> org.eclipse.nebula.widgets.gallery.DefaultGalleryItemRendere r. <init>(DefaultGalleryItemRenderer.java:63)
>
> at
> com.sequenom.everest.ui.project.GalleryView.createPartContro l(GalleryView.java:335)
>
> at
> org.eclipse.ui.internal.ViewReference.createPartHelper(ViewR eference.java:332)
>
> at org.eclipse.ui.internal.ViewReference.createPart(ViewReferen ce.java:197)
> at
> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:566)
>
> at
> org.eclipse.ui.internal.WorkbenchPage$ActivationList.setActi ve(WorkbenchPage.java:3915)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.restoreState(Workbench Page.java:2929)
> at
> org.eclipse.ui.internal.WorkbenchWindow.restoreState(Workben chWindow.java:1936)
>
> at org.eclipse.ui.internal.Workbench.doRestoreState(Workbench.j ava:2857)
> at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1665)
> at org.eclipse.ui.internal.Workbench.access$12(Workbench.java:1 650)
> at org.eclipse.ui.internal.Workbench$17.run(Workbench.java:1529 )
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
> at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1473)
> at
> org.eclipse.ui.internal.WorkbenchConfigurer.restoreState(Wor kbenchConfigur
>
>
> Please help me in this,
>
> Thanks in advance,
> Swetha
>
>
>
Re: Invalid thread access [message #581144 is a reply to message #33176] Wed, 25 April 2007 08:42 Go to previous message
Swetha is currently offline SwethaFriend
Messages: 68
Registered: July 2009
Member
Hi,

That didn't work.. Before it used to run perfectly.. Suddenly the
error is coming..

Thanks,
Swetha
Re: Invalid thread access [message #581160 is a reply to message #33211] Wed, 25 April 2007 09:46 Go to previous message
Nicolas Richeton is currently offline Nicolas RichetonFriend
Messages: 179
Registered: July 2009
Senior Member
Hi,

It's true that the createPart code should be run for the swt thread. I
think you should check your code that is calling this view, because the
problem should be fixed there.

But if you want fix it here, try something like this :

public void createPartControl(Composite parent)
{
Display.getDefault().syncExec( new Runnable() {

void run( ) {
gallery = new Gallery(parent, SWT.V_SCROLL);
noGroupRenderer = new NoGroupRenderer();
defaultGalleryItemRenderer = new
DefaultGalleryItemRenderer();
}
}


}

--
Nicolas

Swetha a écrit :
> Hi,
>
> That didn't work.. Before it used to run perfectly.. Suddenly the
> error is coming..
>
> Thanks,
> Swetha
>
Re: Invalid thread access [message #581179 is a reply to message #33211] Wed, 25 April 2007 09:52 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

I consider this a bug in the Eclipse-Platform and file a bug against it.
It's really a major bug if eclipse is calling createPartControl() out of
the GUI-Thread and many other plugins will fail miserably. So please log
a bug against platform-ui and provide a step to step instruction how to
make this happen!

The work-around from Nicolas will put you on the safe side but please
once more LOG A BUG!

Did you see this behaviour with 3.3M6 or one of the latest I-builds?

Tom

Swetha schrieb:
> Hi,
>
> That didn't work.. Before it used to run perfectly.. Suddenly the
> error is coming..
>
> Thanks,
> Swetha
>
Re: Invalid thread access [message #581205 is a reply to message #33276] Wed, 25 April 2007 10:49 Go to previous message
Swetha is currently offline SwethaFriend
Messages: 68
Registered: July 2009
Member
Hi,

This error is gone.. donno the reason.. I just copied my project in new
workspace and I opened that workspace and run .. working as usual...

In fact my friend also faced the same problem once.. he told to do like
this.. and this is working.. what could be the reason..

Thanks,
Swetha
Re: Invalid thread access [message #581219 is a reply to message #33311] Wed, 25 April 2007 10:55 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

It seems the eclipse is starting a thread when starting up (because of
what ever reason but they forgot to sync the calls with to create part).
Please log a bug against Platform-UI attaching your stacktrace.

Tom

Swetha schrieb:
> Hi,
>
> This error is gone.. donno the reason.. I just copied my project in new
> workspace and I opened that workspace and run .. working as usual...
>
> In fact my friend also faced the same problem once.. he told to do like
> this.. and this is working.. what could be the reason..
>
> Thanks,
> Swetha
>
>
>
Previous Topic:Invalid thread access
Next Topic:CDateTime uses a lot of Windows handles
Goto Forum:
  


Current Time: Fri Mar 29 14:55:15 GMT 2024

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

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

Back to the top