Commit ff1c26d4 authored by Igor Kushnir's avatar Igor Kushnir

Optimize StatusbarProgressWidget::connectSingleItem()

For each progress value report StatusBar::showProgress() calls
ProgressItem::setUsesBusyIndicator(), which eventually results in a call
to StatusbarProgressWidget::connectSingleItem(). The return value of
ProgressManager::instance()->singleItem() changes very rarely between
these calls. Let us avoid reconnecting the same signal/slot pair
repeatedly.
parent 0d87cab9
......@@ -236,12 +236,17 @@ void StatusbarProgressWidget::slotProgressItemCompleted( ProgressItem *item )
void StatusbarProgressWidget::connectSingleItem()
{
auto* const singleItem = ProgressManager::instance()->singleItem();
if ( singleItem == mCurrentItem ) {
return; // No need to waste time reconnecting the same signal/slot pair.
}
if ( mCurrentItem ) {
disconnect ( mCurrentItem, &ProgressItem::progressItemProgress,
this, &StatusbarProgressWidget::slotProgressItemProgress );
mCurrentItem = nullptr;
}
mCurrentItem = ProgressManager::instance()->singleItem();
mCurrentItem = singleItem;
if ( mCurrentItem ) {
connect ( mCurrentItem, &ProgressItem::progressItemProgress,
this, &StatusbarProgressWidget::slotProgressItemProgress );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment