Skip to content

Commit

Permalink
Temporary fix for circular signal
Browse files Browse the repository at this point in the history
  • Loading branch information
afichet committed Oct 23, 2020
1 parent 21a928b commit 143a22f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
35 changes: 18 additions & 17 deletions apps/gui/imagemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void ImageModel::openImage(const QString &filename)
});

_imageLoadingWatcher->setFuture(imageLoading);
recalculateCorrection(0);
recalculateCorrection(0, true);
}


Expand Down Expand Up @@ -249,10 +249,7 @@ void ImageModel::setOutlinePosition(int index, QPointF position)

void ImageModel::setExposure(double value)
{
if (!isImageLoaded()) return;
if (_exposure == value) return;

recalculateCorrection(value);
recalculateCorrection(value, false);
}


Expand Down Expand Up @@ -300,7 +297,7 @@ void ImageModel::setDemosaicingMethod(const QString &method)
});

_imageDemosaicingWatcher->setFuture(demosaicing);
recalculateCorrection(_exposure);
recalculateCorrection(_exposure, true);
}
}

Expand All @@ -312,7 +309,7 @@ void ImageModel::setMatrix(const std::array<float, 9> matrix)
_isMatrixLoaded = true;
_correctionMatrix = matrix;

if (_isMatrixActive) recalculateCorrection(_exposure);
if (_isMatrixActive) recalculateCorrection(_exposure, true);
emit matrixLoaded(_correctionMatrix);
setMatrixActive(true);
}
Expand All @@ -323,7 +320,7 @@ void ImageModel::setMatrixActive(bool active)
if (_isMatrixActive == active) return;

_isMatrixActive = active;
recalculateCorrection(_exposure);
recalculateCorrection(_exposure, true);
emit matrixActivationStateChanged(_isMatrixActive);
}

Expand Down Expand Up @@ -399,8 +396,19 @@ void ImageModel::saveMatrix(const QString &filename)
}


void ImageModel::recalculateCorrection(double exposure)
void ImageModel::recalculateCorrection(double exposure, bool forcedUpdate)
{
if (!forcedUpdate && exposure == _exposure) return;

if (_imageEditingWatcher->isRunning())
{
emit _imageEditingWatcher->cancel();
_imageEditingWatcher->waitForFinished();
}

_exposure = exposure;
emit exposureChanged(_exposure);

if (_imageLoadingWatcher->isRunning())
{
_imageLoadingWatcher->waitForFinished();
Expand All @@ -413,12 +421,6 @@ void ImageModel::recalculateCorrection(double exposure)
_imageDemosaicingWatcher->waitForFinished();
}

if (_imageEditingWatcher->isRunning())
{
emit _imageEditingWatcher->cancel();
_imageEditingWatcher->waitForFinished();
}

QFuture<void> imageEditting = QtConcurrent::run([=]() {
emit processProgress(0);
emit loadingMessage(tr("Exposure correction..."));
Expand Down Expand Up @@ -470,9 +472,8 @@ void ImageModel::recalculateCorrection(double exposure)
emit processProgress(int(100.f * float(y) / float(_image.height() - 1)));
}
}
_exposure = exposure;

emit exposureChanged(_exposure);

emit imageChanged();
emit loadingMessage("");
});
Expand Down
2 changes: 1 addition & 1 deletion apps/gui/imagemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public slots:
void matrixActivationStateChanged(bool state);

protected:
void recalculateCorrection(double exposure);
void recalculateCorrection(double exposure, bool forcedUpdate);
void recalculateMacbethPatches();

private:
Expand Down

0 comments on commit 143a22f

Please sign in to comment.