Fix StatusbarProgressWidget

Authored by antonanikin on Oct 19 2016, 8:11 AM.

Description

Fix StatusbarProgressWidget

Summary: The patch fixes StatusbarProgressWidget for case when some progress item emits percent signals "too often". Old version starts internal delay timer (used to hide short-lived statuses) for 1 second every time when such signal is received. This leads to completely non-showing progress bar for items which sends more than one progress signal during initial 1-second blocking period.

Test Plan:
Tested on master branch.

Code to reproduce bug:

class TestJob : public KJob
{
    Q_OBJECT

public:
    TestJob(int stepTime, int totalTime)
        : KJob(nullptr)
        , m_percent(0.0)
        , m_percentStep(100.0 / totalTime * stepTime )
        , m_stepTime(stepTime)
    {
        m_timer.setSingleShot(false);
        connect(&m_timer, &QTimer::timeout, this, &TestJob::timerSlot);
    }

    void start() override
    {
        m_timer.start(m_stepTime);
    }

private:
    double m_percent;
    double m_percentStep;

    QTimer m_timer;
    int m_stepTime;

    void timerSlot()
    {
        m_percent += m_percentStep;
        if (m_percent >= 100.0)
            m_percent = 100.0;

        setPercent((unsigned long)m_percent);
        if (m_percent == 100.0) {
            emitResult();
            deleteLater();
        }
    }
};

void runTest()
{
    TestJob* testJob = new TestJob(1000, 5000);
    core()->uiController()->registerStatus(new KDevelop::JobStatus(testJob, "testJob"));
    testJob->start();
}

If the value of first parameter of TestJob contructor is less than 1000 - we don't see any status.

Reviewers: KDevelop, kfunk

Reviewed By: KDevelop, kfunk

Subscribers: kfunk, kdevelop-devel

Differential Revision: https://phabricator.kde.org/D3107

Details

Committed
antonanikinOct 19 2016, 8:11 AM
Reviewer
KDevelop
Differential Revision
D3107: Fix StatusbarProgressWidget
Parents
R32:816721d60711: use a different tab bar widget for tabbed documents
Branches
Unknown
Tags
Unknown