Request widgetinfo -> 'Invalid thread access'

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Request widgetinfo -> 'Invalid thread access'

Postby a.bitsche » Tue Aug 22, 2006 3:13 am

I want to add the following lines of code into a sample record i've taken:
Code: Select all
CTabItem widget = (CTabItem)ui.find("MasterPage.mdp.ctabitem");
Point p;
try {
   p = widget.getControl().getSize();
} catch(Exception e) {

"MasterPage.mdp.ctabitem" is registered below.

But if i do so, i get the following error-msg:
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(
at org.eclipse.swt.SWT.error(
at org.eclipse.swt.SWT.error(
at org.eclipse.swt.widgets.Widget.error(
at org.eclipse.swt.widgets.Widget.checkWidget(
at org.eclipse.swt.custom.CTabItem.getControl(

What is wrong?
Thank you for your help!
Last edited by a.bitsche on Thu Sep 14, 2006 11:36 pm, edited 1 time in total.
Posts: 31
Joined: Tue Aug 22, 2006 2:53 am
Location: Austria

RE: Can't get size of registered widget - Exception

Postby Phil Quitslund » Tue Aug 22, 2006 7:01 am

You're seeing this exception because many of the methods on org.eclipse.swt.Widget and its subclasses require that they be called from the UI thread. WindowTester tests, however, are run in a non-UI thread.

To solve this problem in your case, you might try something like this:

CTabItem widget = (CTabItem)ui.find("MasterPage.mdp.ctabitem");
final Point tabSize = new Point(0,0);
//exec on the UI thread...
ui.getDisplay().syncExec(new Runnable() {
public void run() {
Point p = widget.getControl().getSize();
tabSize.x = p.x;
tabSize.y = p.y;

For more on this, see this FAQ entry: ... test_state

Hope this helps!
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest