worker thread, UI thread and GEF [message #184518] |
Tue, 14 June 2005 12:30 |
Eclipse User |
|
|
|
Originally posted by: michel.hassenforder.uha.fr
Hello,
I have a strange problem, here the situation:
I have created a Job which creates repeatedly a new element which is
added to the model. The edit part catches the changes and forwards the
changes to the figure (as usual). After some walk in the figure
hierarchy the framework decides to invalidate the figure and a
DeferedUpdateManager is called. It decides to call the queueWork method
which crashes nicely with a nullPointerException. Lookup the source, I
find that it is due to the fact that the queueWork method asks the
Display to find the display associated to the current thread. It seems
assumed that the current thread IS a UI thread. As my thread is a
“worker” one it is not associated to the UI and the response is null.
And the story ends with the nullPointerException.
My question is: how can I change a model in a non UI (Worker) thread and
of course the UI (part/figure) reflects the change (as usual)?
Thanks in advance
|
|
|
Re: worker thread, UI thread and GEF [message #184624 is a reply to message #184518] |
Wed, 15 June 2005 01:22 |
Eclipse User |
|
|
|
Originally posted by: none.unknown.com
You can't. Draw2d requires such changes to be made on the UI thread. The
fix is that your worker thread should invoke the model change part in
Display.asyncExec() (or syncExec if you need to wait for that task to finish
before proceeding). I am not sure how the jobs framework is set up, but be
careful about deadlocks.
"Michel Hassenforder" <michel.hassenforder@uha.fr> wrote in message
news:d8mile$gnb$1@news.eclipse.org...
> Hello,
>
> I have a strange problem, here the situation:
>
> I have created a Job which creates repeatedly a new element which is
> added to the model. The edit part catches the changes and forwards the
> changes to the figure (as usual). After some walk in the figure
> hierarchy the framework decides to invalidate the figure and a
> DeferedUpdateManager is called. It decides to call the queueWork method
> which crashes nicely with a nullPointerException. Lookup the source, I
> find that it is due to the fact that the queueWork method asks the
> Display to find the display associated to the current thread. It seems
> assumed that the current thread IS a UI thread. As my thread is a
>
|
|
|
Re: worker thread, UI thread and GEF [message #184640 is a reply to message #184624] |
Wed, 15 June 2005 06:32 |
Eclipse User |
|
|
|
Originally posted by: michel.hassenforder.uha.fr
Thank you for the reply.
It was what I haved guessed.
I will look around the Display.asyncExec() to see if it can solve the
problem.
Pratik Shah a écrit :
> You can't. Draw2d requires such changes to be made on the UI thread. The
> fix is that your worker thread should invoke the model change part in
> Display.asyncExec() (or syncExec if you need to wait for that task to finish
> before proceeding). I am not sure how the jobs framework is set up, but be
> careful about deadlocks.
>
> "Michel Hassenforder" <michel.hassenforder@uha.fr> wrote in message
> news:d8mile$gnb$1@news.eclipse.org...
>
>>Hello,
>>
>>I have a strange problem, here the situation:
>>
>>I have created a Job which creates repeatedly a new element which is
>>added to the model. The edit part catches the changes and forwards the
>>changes to the figure (as usual). After some walk in the figure
>>hierarchy the framework decides to invalidate the figure and a
>>DeferedUpdateManager is called. It decides to call the queueWork method
>>which crashes nicely with a nullPointerException. Lookup the source, I
>>find that it is due to the fact that the queueWork method asks the
>>Display to find the display associated to the current thread. It seems
>>assumed that the current thread IS a UI thread. As my thread is a
>>“worker” one it is not associated to the UI and the response is null.
>>And the story ends with the nullPointerException.
>>
>>My question is: how can I change a model in a non UI (Worker) thread and
>>of course the UI (part/figure) reflects the change (as usual)?
>>
>>Thanks in advance
>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03258 seconds