[Ctk-developers] workflow framework and threads
Miklos Espak
espakm at gmail.com
Tue Nov 1 16:58:03 UTC 2011
Hi,
could you (or anybody), eventually, have a look at the test that I shared?
As a workaround I disabled the Next button until the computation finishes
(between the onExit and the onExitComplete signal), but it treats only one
symptom.
Now I ran into the problem again, and I do not know what to do with this.
Step2 relies on some data that Step1 creates in the onExitComplete
function. However, because of the bug, the data is not ready. The events
happen in this order:
Step1 onExit
Step2 onEntry
Step2 createUserInterface
Step1 onExitComplete
In my opinion, the step1 onExitComplete should be invoked before step2
onEntry.
Even, it would not be bad if the user interface was ready before the
onEntry signal, but it is not so important.
Thanks,
Miklos
On Tue, Oct 25, 2011 at 3:11 PM, Miklos Espak <espakm at gmail.com> wrote:
> Hi,
>
> I added a new test. You can run it by
>
> $ ./CTKWidgetsCppTests ctkExampleUseOfWorkflowWidgetUsingThreads -I
>
> in the project bin directory.
>
> The onExit function of the steps start a thread that waits for 5 sec
> ("calculation"). The onExitComplete signal is sent when the thread finishes.
>
> If you press the Next button, the "calculation" starts and after 5 sec you
> get to the next page. That is fine. However, if you press Next within this
> period, the thread of the second step will start, although the first step
> has not finished. (It has not sent the onExitComplete signal.)
>
> You can checkout the test via GitHub:
>
> https://github.com/commontk/CTK/issues/61
>
> Thanks for dealing with this issue!
>
> Best,
> Miklos
>
> On Mon, Oct 24, 2011 at 11:47 PM, Miklos Espak <espakm at gmail.com> wrote:
>
>> By running the step in a different thread, what do you mean exactly ?
>>>
>>
>> Sorry, I was not clear. I run some calculations (ITK filters) in the
>> workflow steps, and I start them in a new thread. The workflow step listens
>> to the "finished" and "terminated" signal of the thread and it signals
>> "onExitCompleted" after the thread is finished.
>>
>>
>>> As a side note: "Although QObject<http://doc.qt.nokia.com/stable/qobject.html>is reentrant, the GUI classes, notably
>>> QWidget <http://doc.qt.nokia.com/stable/qwidget.html> and all its
>>> subclasses, are not reentrant. They can only be used from the main thread."
>>> See http://doc.qt.nokia.com/stable/threads-qobject.html
>>>
>>
>> Yes, I had some troubles because of this, but I solved them. I refactored
>> every GUI access from the function that runs the calculation. E.g. the
>> thread that runs the calculation notifies the GUI thread through signals
>> about the progress of the internal ITK filters. In this way the thread does
>> not need to access the progress bar.
>>
>> Would it be possible for you to share some code ? May a topic on your CTK
>>>> fork ?
>>>>
>>>
>> Yes, I will upload a sample app tomorrow.
>>
>> Thanks,
>> Miklos
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/ctk-developers/attachments/20111101/e5fde796/attachment.htm>
More information about the Ctk-developers
mailing list