Commit ab548348 authored by Dmitry Kazakov's avatar Dmitry Kazakov Committed by Boudewijn Rempt

Avoid race conditions in the destruction of KisBusyProgressIndicator

BUG:353638
parent 9e743fec
......@@ -26,7 +26,7 @@
struct KisBusyProgressIndicator::Private
{
Private() : numEmptyTicks(0) {}
Private() : numEmptyTicks(0), isStarted(false) {}
QTimer timer;
int numEmptyTicks;
......@@ -34,13 +34,19 @@ struct KisBusyProgressIndicator::Private
QAtomicInt timerStarted;
KoProgressProxy *progressProxy;
bool isStarted;
void startProgressReport() {
isStarted = true;
progressProxy->setRange(0, 0);
}
void stopProgressReport() {
if (!isStarted) return;
progressProxy->setRange(0, 100);
progressProxy->setValue(100);
isStarted = false;
}
};
......@@ -59,6 +65,11 @@ KisBusyProgressIndicator::~KisBusyProgressIndicator()
m_d->stopProgressReport();
}
void KisBusyProgressIndicator::endUpdatesBeforeDestroying()
{
m_d->stopProgressReport();
}
void KisBusyProgressIndicator::timerFinished()
{
int value = m_d->numUpdates.fetchAndStoreOrdered(0);
......
......@@ -32,6 +32,8 @@ public:
KisBusyProgressIndicator(KoProgressProxy *progressProxy);
~KisBusyProgressIndicator();
void endUpdatesBeforeDestroying();
public Q_SLOTS:
void update();
......
......@@ -202,6 +202,7 @@ KisNode::KisNode(const KisNode & rhs)
KisNode::~KisNode()
{
if (m_d->busyProgressIndicator) {
m_d->busyProgressIndicator->endUpdatesBeforeDestroying();
m_d->busyProgressIndicator->deleteLater();
}
......
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