Page MenuHomePhabricator

Change progress bar default assumption on threading
Closed, WontfixPublic

Description

mitk::ProgressBar can be used from threads. The methods "AddStepsToDo" and "Progress" take a bool parameter "callFromThread" for this purpose.

When the parameter "callFromThread" is set, the event which leads to an update of the Qt GUI (visible progress bar) is only posted to the Qt event loop -- i.e. the progress bar update only happens when Qt processes the event loop, which is always from the GUI thread.

Currently, the default value of callFromThread is false.

I suggest changing the default value of callFromThread to true for this reason:
the programmer who implements an MITK filter cannot know in advance whether his filter will be used from a thread or from the "normal thread / Qt's GUI thread". Since using ProgressBar from a thread and setting callFromThread to false inevitably leads to crashes, the only safe assumption of a filter programmer is to assume the filter is called from a thread and set the parameter accordingly.

To prevent everybody from setting this parameter explicitly, I suggest to change its default to true.

I cannot see any side effect. The implementation will be insignificantly slower for non-threaded applications.

Event Timeline

Marco, could you check the core modification?

Maybe a solution could be to use the Qt Signal/Slot mechanism to pass the message to the gui thread?

--> http://doc.trolltech.com/4.5/threads.html#signals-and-slots-across-threads

by now this could be a possible solution. the alternative using the message queue is already implemented. I would favor creating a quick solution and then opening a new ticket (on changing the mechanism to signal/slots) with lower priority.

Ok, after further inspection of mitk::ProgressBar, I don't want to change stuff as described previously. Instead, I'll open a new bug to change the strange design of ProgressBar..

Hi, your bug is resolved, can you please remove the needs_core_modification request (set it to - or nothing)? Otherwise it clutters the list of open requests which is not filterable by status.

This will help granting the flag for open bugs much faster ;)

kislinsk added a project: Bulk Edit.
kislinsk removed a project: Bulk Edit.