Commit f7131ceb authored by Spencer Brown's avatar Spencer Brown
Browse files

Fixed bug 333142: Krita crashed when generating random noise with filter

https://bugs.kde.org/show_bug.cgi?id=333142

Fixed as per Dmitry's suggestion to remove the for loop entirely.
The progress updater still doesn't work correctly.
parent ae131dc3
......@@ -139,20 +139,18 @@ void KisFilterNoise::processImpl(KisPaintDeviceSP device,
KisRandomGenerator randg(seedGreen);
KisRandomGenerator randb(seedBlue);
for (int row = 0; row < applyRect.height() && !(progressUpdater && progressUpdater->interrupted()); ++row) {
do {
if (randt.doubleRandomAt(it.x(), it.y()) > threshold) {
// XXX: Added static_cast to get rid of warnings
QColor c = qRgb(static_cast<int>((double)randr.doubleRandomAt(it.x(), it.y()) * 255),
static_cast<int>((double)randg.doubleRandomAt(it.x(), it.y()) * 255),
static_cast<int>((double)randb.doubleRandomAt(it.x(), it.y()) * 255));
cs->fromQColor(c, interm, 0);
pixels[1] = it.oldRawData();
mixOp->mixColors(pixels, weights, 2, it.rawData());
}
if (progressUpdater) progressUpdater->setValue(++count);
} while (it.nextPixel() && !(progressUpdater && progressUpdater->interrupted()));
}
do {
if (randt.doubleRandomAt(it.x(), it.y()) > threshold) {
// XXX: Added static_cast to get rid of warnings
QColor c = qRgb(static_cast<int>((double)randr.doubleRandomAt(it.x(), it.y()) * 255),
static_cast<int>((double)randg.doubleRandomAt(it.x(), it.y()) * 255),
static_cast<int>((double)randb.doubleRandomAt(it.x(), it.y()) * 255));
cs->fromQColor(c, interm, 0);
pixels[1] = it.oldRawData();
mixOp->mixColors(pixels, weights, 2, it.rawData());
}
if (progressUpdater) progressUpdater->setValue(++count);
} while (it.nextPixel() && !(progressUpdater && progressUpdater->interrupted()));
delete [] interm;
}
......
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