Commit abac56c1 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix GCC warnings about catching by value

One should stick to the rule: "throw by value, catch by reference"
parent ca1b82fa
......@@ -87,7 +87,7 @@ void KisFilter::process(const KisPaintDeviceSP src,
processImpl(temporary, applyRect, config, progressUpdater);
}
catch (std::bad_alloc) {
catch (const std::bad_alloc&) {
warnKrita << "Filter" << name() << "failed to allocate enough memory to run.";
}
......
......@@ -223,7 +223,7 @@ QImage KisBaseNode::createThumbnail(qint32 w, qint32 h)
QImage image(w, h, QImage::Format_ARGB32);
image.fill(0);
return image;
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
return QImage();
}
......
......@@ -211,7 +211,7 @@ QImage KisFixedPaintDevice::convertToQImage(const KoColorProfile * dstProfile,
QImage image = colorSpace()->convertToQImage(newData, w, h, dstProfile, intent, conversionFlags);
return image;
}
catch(std::bad_alloc) {
catch(const std::bad_alloc&) {
return QImage();
}
}
......
......@@ -159,7 +159,7 @@ QVector<QPolygon> KisOutlineGenerator::outlineImpl(typename StorageStrategy::Sto
}
}
}
catch(std::bad_alloc) {
catch(const std::bad_alloc&) {
warnKrita << "KisOutlineGenerator::outline ran out of memory allocating " << width << "*" << height << "marks";
}
......
......@@ -1549,7 +1549,7 @@ void KisPaintDevice::convertFromQImage(const QImage& _image, const KoColorProfil
writeBytes(dstData, offsetX, offsetY, image.width(), image.height());
delete[] dstData;
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
warnKrita << "KisPaintDevice::convertFromQImage: Could not allocate" << image.width() * image.height() * pixelSize() << "bytes";
return;
}
......@@ -1595,7 +1595,7 @@ QImage KisPaintDevice::convertToQImage(const KoColorProfile *dstProfile, qint32
quint8 *data = 0;
try {
data = new quint8 [w * h * pixelSize()];
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
warnKrita << "KisPaintDevice::convertToQImage std::bad_alloc for " << w << " * " << h << " * " << pixelSize();
//delete[] data; // data is not allocated, so don't free it
return QImage();
......
......@@ -513,7 +513,7 @@ void KisPainter::bitBltWithFixedSelection(qint32 dstX, qint32 dstY,
quint8* dstBytes = 0;
try {
dstBytes = new quint8[srcWidth * srcHeight * d->device->pixelSize()];
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
warnKrita << "KisPainter::bitBltWithFixedSelection std::bad_alloc for " << srcWidth << " * " << srcHeight << " * " << d->device->pixelSize() << "dst bytes";
return;
}
......@@ -524,7 +524,7 @@ void KisPainter::bitBltWithFixedSelection(qint32 dstX, qint32 dstY,
quint8* srcBytes = 0;
try {
srcBytes = new quint8[srcWidth * srcHeight * srcDev->pixelSize()];
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
warnKrita << "KisPainter::bitBltWithFixedSelection std::bad_alloc for " << srcWidth << " * " << srcHeight << " * " << d->device->pixelSize() << "src bytes";
return;
}
......@@ -558,7 +558,7 @@ void KisPainter::bitBltWithFixedSelection(qint32 dstX, qint32 dstY,
quint8* mergedSelectionBytes = 0;
try {
mergedSelectionBytes = new quint8[ totalBytes ];
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
warnKrita << "KisPainter::bitBltWithFixedSelection std::bad_alloc for " << srcWidth << " * " << srcHeight << " * " << d->device->pixelSize() << "total bytes";
return;
}
......@@ -915,7 +915,7 @@ void KisPainter::bltFixed(qint32 dstX, qint32 dstY,
quint8* dstBytes = 0;
try {
dstBytes = new quint8[srcWidth * srcHeight * d->device->pixelSize()];
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
warnKrita << "KisPainter::bltFixed std::bad_alloc for " << srcWidth << " * " << srcHeight << " * " << d->device->pixelSize() << "total bytes";
return;
}
......@@ -941,7 +941,7 @@ void KisPainter::bltFixed(qint32 dstX, qint32 dstY,
try {
selBytes = new quint8[srcWidth * srcHeight * selectionProjection->pixelSize()];
}
catch (std::bad_alloc) {
catch (const std::bad_alloc&) {
delete[] dstBytes;
return;
}
......@@ -1002,7 +1002,7 @@ void KisPainter::bltFixedWithFixedSelection(qint32 dstX, qint32 dstY,
quint8* dstBytes = 0;
try {
dstBytes = new quint8[srcWidth * srcHeight * d->device->pixelSize()];
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
warnKrita << "KisPainter::bltFixedWithFixedSelection std::bad_alloc for " << srcWidth << " * " << srcHeight << " * " << d->device->pixelSize() << "total bytes";
return;
}
......@@ -1033,7 +1033,7 @@ void KisPainter::bltFixedWithFixedSelection(qint32 dstX, qint32 dstY,
quint8 * mergedSelectionBytes = 0;
try {
mergedSelectionBytes = new quint8[ totalBytes ];
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
warnKrita << "KisPainter::bltFixedWithFixedSelection std::bad_alloc for " << totalBytes << "total bytes";
delete[] dstBytes;
return;
......
......@@ -384,7 +384,7 @@ QVector<QPolygon> KisPixelSelection::outline() const
delete[] buffer;
return paths;
}
catch(std::bad_alloc) {
catch(const std::bad_alloc&) {
// Allocating so much memory failed, so we fall through to the slow option.
warnKrita << "KisPixelSelection::outline ran out of memory allocating" << width << "*" << height << "bytes.";
}
......
......@@ -676,7 +676,7 @@ KisImageBuilder_Result KisPNGConverter::buildImage(QIODevice* iod)
} else {
reader.reset(new KisPNGReaderLineByLine(png_ptr, info_ptr, width, height));
}
} catch (std::bad_alloc& e) {
} catch (const std::bad_alloc& e) {
// new png_byte[] may raise such an exception if the image
// is invalid / to large.
dbgFile << "bad alloc: " << e.what();
......
......@@ -81,13 +81,13 @@ void KisWaveletNoiseReduction::processImpl(KisPaintDeviceSP device,
try {
buff = mathToolbox.initWavelet(device, applyRect);
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
if (buff) delete buff;
return;
}
try {
wav = mathToolbox.fastWaveletTransformation(device, applyRect, buff);
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
if (wav) delete wav;
return;
}
......
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