summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qbrush.cpp10
-rw-r--r--src/gui/painting/qbrush.h4
-rw-r--r--src/gui/painting/qgrayraster.c4
-rw-r--r--src/gui/painting/qpaintengine.h2
-rw-r--r--src/gui/painting/qpaintengine_alpha_p.h2
-rw-r--r--src/gui/painting/qpaintengine_mac_p.h2
-rw-r--r--src/gui/painting/qpaintengine_preview_p.h2
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp98
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h16
-rw-r--r--src/gui/painting/qpaintengine_x11.cpp2
-rw-r--r--src/gui/painting/qpaintengine_x11_p.h2
-rw-r--r--src/gui/painting/qpaintengineex_p.h2
-rw-r--r--src/gui/painting/qpainter.cpp19
-rw-r--r--src/gui/painting/qpainter.h6
-rw-r--r--src/gui/painting/qpainterpath.cpp9
-rw-r--r--src/gui/painting/qpainterpath.h8
-rw-r--r--src/gui/painting/qpdf_p.h2
-rw-r--r--src/gui/painting/qprintengine_mac_p.h2
-rw-r--r--src/gui/painting/qprintengine_pdf_p.h2
-rw-r--r--src/gui/painting/qprintengine_ps_p.h2
-rw-r--r--src/gui/painting/qprintengine_qws_p.h2
-rw-r--r--src/gui/painting/qprintengine_win_p.h2
-rw-r--r--src/gui/painting/qprinter.h2
-rw-r--r--src/gui/painting/qprinterinfo.h6
-rw-r--r--src/gui/painting/qprinterinfo_mac.cpp8
-rw-r--r--src/gui/painting/qprinterinfo_unix.cpp8
-rw-r--r--src/gui/painting/qprinterinfo_win.cpp8
-rw-r--r--src/gui/painting/qrasterizer.cpp4
-rw-r--r--src/gui/painting/qtessellator.cpp12
-rw-r--r--src/gui/painting/qwindowsurface_raster_p.h2
-rw-r--r--src/gui/painting/qwindowsurface_s60.cpp9
31 files changed, 104 insertions, 155 deletions
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 519e02e885..97cbecc51c 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -230,7 +230,7 @@ struct QGradientBrushData : public QBrushData
QGradient gradient;
};
-struct QBrushDataPointerHandler
+struct QBrushDataPointerDeleter
{
static inline void deleteData(QBrushData *d)
{
@@ -254,12 +254,6 @@ struct QBrushDataPointerHandler
deleteData(d);
}
}
-
- static inline void reset(QBrushData *&d, QBrushData *other)
- {
- cleanup(d);
- d = other;
- }
};
/*!
@@ -580,7 +574,7 @@ QBrush::~QBrush()
void QBrush::cleanUp(QBrushData *x)
{
- QBrushDataPointerHandler::deleteData(x);
+ QBrushDataPointerDeleter::deleteData(x);
}
diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h
index 5479305de0..69adee2fb1 100644
--- a/src/gui/painting/qbrush.h
+++ b/src/gui/painting/qbrush.h
@@ -62,7 +62,7 @@ struct QBrushData;
class QPixmap;
class QGradient;
class QVariant;
-struct QBrushDataPointerHandler;
+struct QBrushDataPointerDeleter;
class Q_GUI_EXPORT QBrush
{
@@ -128,7 +128,7 @@ private:
friend bool Q_GUI_EXPORT qHasPixmapTexture(const QBrush& brush);
void detach(Qt::BrushStyle newStyle);
void init(const QColor &color, Qt::BrushStyle bs);
- QScopedCustomPointer<QBrushData, QBrushDataPointerHandler> d;
+ QCustomScopedPointer<QBrushData, QBrushDataPointerDeleter> d;
void cleanUp(QBrushData *x);
public:
diff --git a/src/gui/painting/qgrayraster.c b/src/gui/painting/qgrayraster.c
index 888fd9adb0..f908d4803d 100644
--- a/src/gui/painting/qgrayraster.c
+++ b/src/gui/painting/qgrayraster.c
@@ -1880,6 +1880,10 @@
if (memory)
fprintf(stderr, "gray_raster_new(), memory ignored");
memory = malloc(sizeof(TRaster));
+ if (!memory) {
+ *araster = 0;
+ return ErrRaster_Memory_Overflow;
+ }
QT_FT_MEM_ZERO(memory, sizeof(TRaster));
*araster = (QT_FT_Raster) memory;
diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h
index 92aa506c7f..6460afa657 100644
--- a/src/gui/painting/qpaintengine.h
+++ b/src/gui/painting/qpaintengine.h
@@ -89,7 +89,7 @@ Q_DECLARE_TYPEINFO(QTextItem, Q_PRIMITIVE_TYPE);
class Q_GUI_EXPORT QPaintEngine
{
- Q_DECLARE_PRIVATE(QPaintEngine)
+ Q_DECLARE_SCOPED_PRIVATE(QPaintEngine)
public:
enum PaintEngineFeature {
PrimitiveTransform = 0x00000001, // Can transform primitives brushes
diff --git a/src/gui/painting/qpaintengine_alpha_p.h b/src/gui/painting/qpaintengine_alpha_p.h
index 7f45ad6a7d..1a0b1ac605 100644
--- a/src/gui/painting/qpaintengine_alpha_p.h
+++ b/src/gui/painting/qpaintengine_alpha_p.h
@@ -62,7 +62,7 @@ class QAlphaPaintEnginePrivate;
class QAlphaPaintEngine : public QPaintEngine
{
- Q_DECLARE_PRIVATE(QAlphaPaintEngine)
+ Q_DECLARE_SCOPED_PRIVATE(QAlphaPaintEngine)
public:
~QAlphaPaintEngine();
diff --git a/src/gui/painting/qpaintengine_mac_p.h b/src/gui/painting/qpaintengine_mac_p.h
index 755b7b1d58..58150d0da0 100644
--- a/src/gui/painting/qpaintengine_mac_p.h
+++ b/src/gui/painting/qpaintengine_mac_p.h
@@ -174,7 +174,7 @@ public:
class QCoreGraphicsPaintEnginePrivate;
class QCoreGraphicsPaintEngine : public QPaintEngine
{
- Q_DECLARE_PRIVATE(QCoreGraphicsPaintEngine)
+ Q_DECLARE_SCOPED_PRIVATE(QCoreGraphicsPaintEngine)
public:
QCoreGraphicsPaintEngine();
diff --git a/src/gui/painting/qpaintengine_preview_p.h b/src/gui/painting/qpaintengine_preview_p.h
index 9f96d4016e..d8e2b08985 100644
--- a/src/gui/painting/qpaintengine_preview_p.h
+++ b/src/gui/painting/qpaintengine_preview_p.h
@@ -65,7 +65,7 @@ class QPreviewPaintEnginePrivate;
class QPreviewPaintEngine : public QPaintEngine, public QPrintEngine
{
- Q_DECLARE_PRIVATE(QPreviewPaintEngine)
+ Q_DECLARE_SCOPED_PRIVATE(QPreviewPaintEngine)
public:
QPreviewPaintEngine();
~QPreviewPaintEngine();
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index c5e342cf5e..ead335583b 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -351,30 +351,33 @@ void QRasterPaintEngine::init()
Q_CHECK_PTR(d->rasterPoolBase);
// The antialiasing raster.
- d->grayRaster = new QT_FT_Raster;
- qt_ft_grays_raster.raster_new(0, d->grayRaster);
- qt_ft_grays_raster.raster_reset(*d->grayRaster, d->rasterPoolBase, d->rasterPoolSize);
+ d->grayRaster.reset(new QT_FT_Raster);
+ Q_CHECK_PTR(d->grayRaster.data());
+ if (qt_ft_grays_raster.raster_new(0, d->grayRaster.data()))
+ QT_THROW(std::bad_alloc()); // an error creating the raster is caused by a bad malloc
- d->rasterizer = new QRasterizer;
- d->rasterBuffer = new QRasterBuffer();
- d->outlineMapper = new QOutlineMapper;
+
+ qt_ft_grays_raster.raster_reset(*d->grayRaster.data(), d->rasterPoolBase, d->rasterPoolSize);
+
+ d->rasterizer.reset(new QRasterizer);
+ d->rasterBuffer.reset(new QRasterBuffer());
+ d->outlineMapper.reset(new QOutlineMapper);
d->outlinemapper_xform_dirty = true;
d->basicStroker.setMoveToHook(qt_ft_outline_move_to);
d->basicStroker.setLineToHook(qt_ft_outline_line_to);
d->basicStroker.setCubicToHook(qt_ft_outline_cubic_to);
- d->dashStroker = 0;
- d->baseClip = new QClipData(d->device->height());
+ d->baseClip.reset(new QClipData(d->device->height()));
d->baseClip->setClipRect(QRect(0, 0, d->device->width(), d->device->height()));
- d->image_filler.init(d->rasterBuffer, this);
+ d->image_filler.init(d->rasterBuffer.data(), this);
d->image_filler.type = QSpanData::Texture;
- d->image_filler_xform.init(d->rasterBuffer, this);
+ d->image_filler_xform.init(d->rasterBuffer.data(), this);
d->image_filler_xform.type = QSpanData::Texture;
- d->solid_color_filler.init(d->rasterBuffer, this);
+ d->solid_color_filler.init(d->rasterBuffer.data(), this);
d->solid_color_filler.type = QSpanData::Solid;
d->deviceDepth = d->device->depth();
@@ -443,15 +446,7 @@ QRasterPaintEngine::~QRasterPaintEngine()
free(d->rasterPoolBase);
#endif
- qt_ft_grays_raster.raster_done(*d->grayRaster);
- delete d->grayRaster;
-
- delete d->rasterBuffer;
- delete d->outlineMapper;
- delete d->rasterizer;
- delete d->dashStroker;
-
- delete d->baseClip;
+ qt_ft_grays_raster.raster_done(*d->grayRaster.data());
}
/*!
@@ -487,12 +482,12 @@ bool QRasterPaintEngine::begin(QPaintDevice *device)
d->rasterizer->setClipRect(d->deviceRect);
- s->penData.init(d->rasterBuffer, this);
+ s->penData.init(d->rasterBuffer.data(), this);
s->penData.setup(s->pen.brush(), s->intOpacity, s->composition_mode);
s->stroker = &d->basicStroker;
d->basicStroker.setClipRect(d->deviceRect);
- s->brushData.init(d->rasterBuffer, this);
+ s->brushData.init(d->rasterBuffer.data(), this);
s->brushData.setup(s->brush, s->intOpacity, s->composition_mode);
d->rasterBuffer->compositionMode = QPainter::CompositionMode_SourceOver;
@@ -556,8 +551,7 @@ bool QRasterPaintEngine::end()
void QRasterPaintEngine::releaseBuffer()
{
Q_D(QRasterPaintEngine);
- delete d->rasterBuffer;
- d->rasterBuffer = new QRasterBuffer;
+ d->rasterBuffer.reset(new QRasterBuffer);
}
/*!
@@ -801,8 +795,8 @@ void QRasterPaintEngine::updatePen(const QPen &pen)
if(pen_style == Qt::SolidLine) {
s->stroker = &d->basicStroker;
} else if (pen_style != Qt::NoPen) {
- if (!d->dashStroker)
- d->dashStroker = new QDashStroker(&d->basicStroker);
+ if (!d->dashStroker.data())
+ d->dashStroker.reset(new QDashStroker(&d->basicStroker));
if (pen.isCosmetic()) {
d->dashStroker->setClipRect(d->deviceRect);
} else {
@@ -812,7 +806,7 @@ void QRasterPaintEngine::updatePen(const QPen &pen)
}
d->dashStroker->setDashPattern(pen.dashPattern());
d->dashStroker->setDashOffset(pen.dashOffset());
- s->stroker = d->dashStroker;
+ s->stroker = d->dashStroker.data();
} else {
s->stroker = 0;
}
@@ -1245,7 +1239,7 @@ void QRasterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
qrasterpaintengine_state_setNoClip(s);
} else {
- QClipData *base = d->baseClip;
+ QClipData *base = d->baseClip.data();
// Intersect with current clip when available...
if (op == Qt::IntersectClip && s->clip)
@@ -1370,7 +1364,7 @@ void QRasterPaintEngine::clip(const QRegion &region, Qt::ClipOperation op)
QRasterPaintEngineState *s = state();
const QClipData *clip = d->clip();
- const QClipData *baseClip = d->baseClip;
+ const QClipData *baseClip = d->baseClip.data();
if (op == Qt::NoClip) {
qrasterpaintengine_state_setNoClip(s);
@@ -1438,7 +1432,7 @@ void QRasterPaintEngine::fillPath(const QPainterPath &path, QSpanData *fillData)
}
ensureOutlineMapper();
- d->rasterize(d->outlineMapper->convertPath(path), blend, fillData, d->rasterBuffer);
+ d->rasterize(d->outlineMapper->convertPath(path), blend, fillData, d->rasterBuffer.data());
}
static void fillRect_normalized(const QRect &r, QSpanData *data,
@@ -1699,7 +1693,7 @@ void QRasterPaintEnginePrivate::strokeProjective(const QPainterPath &path)
? pathStroker.createStroke(s->matrix.map(path))
: s->matrix.map(pathStroker.createStroke(path));
- rasterize(outlineMapper->convertPath(stroke), s->penData.blend, &s->penData, rasterBuffer);
+ rasterize(outlineMapper->convertPath(stroke), s->penData.blend, &s->penData, rasterBuffer.data());
outlinemapper_xform_dirty = true;
}
@@ -1875,7 +1869,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
// }
ensureOutlineMapper();
- d->rasterize(d->outlineMapper->convertPath(path), blend, &s->brushData, d->rasterBuffer);
+ d->rasterize(d->outlineMapper->convertPath(path), blend, &s->brushData, d->rasterBuffer.data());
}
void QRasterPaintEngine::fillRect(const QRectF &r, QSpanData *data)
@@ -1996,20 +1990,20 @@ void QRasterPaintEngine::drawPath(const QPainterPath &path)
d->dashStroker->setClipRect(d->deviceRect);
d->basicStroker.setStrokeWidth(strokeWidth * txscale);
d->outlineMapper->setMatrix(QTransform());
- s->stroker->strokePath(path, d->outlineMapper, s->matrix);
+ s->stroker->strokePath(path, d->outlineMapper.data(), s->matrix);
d->outlinemapper_xform_dirty = true;
d->basicStroker.setStrokeWidth(strokeWidth);
- if (d->dashStroker)
+ if (d->dashStroker.data())
d->dashStroker->setClipRect(clipRect);
} else {
ensureOutlineMapper();
- s->stroker->strokePath(path, d->outlineMapper, QTransform());
+ s->stroker->strokePath(path, d->outlineMapper.data(), QTransform());
}
d->outlineMapper->endOutline();
ProcessSpans blend = d->getPenFunc(d->outlineMapper->controlPointRect,
&s->penData);
- d->rasterize(d->outlineMapper->outline(), blend, &s->penData, d->rasterBuffer);
+ d->rasterize(d->outlineMapper->outline(), blend, &s->penData, d->rasterBuffer.data());
}
}
@@ -2103,7 +2097,7 @@ void QRasterPaintEngine::fillPolygon(const QPointF *points, int pointCount, Poly
// scanconvert.
ProcessSpans brushBlend = d->getBrushFunc(d->outlineMapper->controlPointRect,
&s->brushData);
- d->rasterize(outline, brushBlend, &s->brushData, d->rasterBuffer);
+ d->rasterize(outline, brushBlend, &s->brushData, d->rasterBuffer.data());
}
/*!
@@ -2199,7 +2193,7 @@ void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, Polyg
// scanconvert.
ProcessSpans brushBlend = d->getBrushFunc(d->outlineMapper->controlPointRect,
&s->brushData);
- d->rasterize(d->outlineMapper->outline(), brushBlend, &s->brushData, d->rasterBuffer);
+ d->rasterize(d->outlineMapper->outline(), brushBlend, &s->brushData, d->rasterBuffer.data());
d->outlineMapper->setCoordinateRounding(false);
}
}
@@ -2824,7 +2818,7 @@ void QRasterPaintEngine::alphaPenBlt(const void* src, int bpl, int depth, int rx
if (!s->penData.blend)
return;
- QRasterBuffer *rb = d->rasterBuffer;
+ QRasterBuffer *rb = d->rasterBuffer.data();
const QRect rect(rx, ry, w, h);
const QClipData *clip = d->clip();
@@ -4086,7 +4080,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline,
rasterParams.flags |= (QT_FT_RASTER_FLAG_AA | QT_FT_RASTER_FLAG_DIRECT);
rasterParams.gray_spans = callback;
- error = qt_ft_grays_raster.raster_render(*grayRaster, &rasterParams);
+ error = qt_ft_grays_raster.raster_render(*grayRaster.data(), &rasterParams);
// Out of memory, reallocate some more and try again...
if (error == -6) { // -6 is Result_err_OutOfMemory
@@ -4113,9 +4107,9 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline,
#endif
Q_CHECK_PTR(rasterPoolBase); // note: we just freed the old rasterPoolBase. I hope it's not fatal.
- qt_ft_grays_raster.raster_done(*grayRaster);
- qt_ft_grays_raster.raster_new(0, grayRaster);
- qt_ft_grays_raster.raster_reset(*grayRaster, rasterPoolBase, rasterPoolSize);
+ qt_ft_grays_raster.raster_done(*grayRaster.data());
+ qt_ft_grays_raster.raster_new(0, grayRaster.data());
+ qt_ft_grays_raster.raster_reset(*grayRaster.data(), rasterPoolBase, rasterPoolSize);
} else {
done = true;
}
@@ -4149,6 +4143,8 @@ QImage QRasterBuffer::colorizeBitmap(const QImage &image, const QColor &color)
for (int y=0; y<height; ++y) {
uchar *source = sourceImage.scanLine(y);
QRgb *target = reinterpret_cast<QRgb *>(dest.scanLine(y));
+ if (!source || !target)
+ QT_THROW(std::bad_alloc()); // we must have run out of memory
for (int x=0; x < width; ++x)
target[x] = (source[x>>3] >> (x&7)) & 1 ? fg : bg;
}
@@ -4352,7 +4348,7 @@ void QClipData::initialize()
Q_CHECK_PTR(m_clipLines);
QT_TRY {
m_spans = (QSpan *)malloc(clipSpanHeight*sizeof(QSpan));
- allocated = clipSpanHeight;
+ allocated = clipSpanHeight;
Q_CHECK_PTR(m_spans);
QT_TRY {
@@ -4392,9 +4388,7 @@ void QClipData::initialize()
{ // resize
const int maxSpans = (ymax - ymin) * numRects;
if (maxSpans > allocated) {
- QSpan *newSpans = (QSpan *)realloc(m_spans, maxSpans * sizeof(QSpan));
- Q_CHECK_PTR(newSpans);
- m_spans = newSpans;
+ m_spans = q_check_ptr((QSpan *)realloc(m_spans, maxSpans * sizeof(QSpan)));
allocated = maxSpans;
}
}
@@ -4446,11 +4440,13 @@ void QClipData::initialize()
}
} QT_CATCH(...) {
- free(m_spans);
+ free(m_spans); // have to free m_spans again or someone might think that we were successfully initialized.
+ m_spans = 0;
QT_RETHROW;
}
} QT_CATCH(...) {
- free(m_clipLines);
+ free(m_clipLines); // same for clipLines
+ m_clipLines = 0;
QT_RETHROW;
}
}
@@ -4824,9 +4820,7 @@ static void qt_span_clip(int count, const QSpan *spans, void *userData)
&newspans, newClip->allocated - newClip->count);
newClip->count = newspans - newClip->m_spans;
if (spans < end) {
- QSpan *newSpan = (QSpan *)realloc(newClip->m_spans, newClip->allocated*2*sizeof(QSpan));
- Q_CHECK_PTR(newSpan);
- newClip->m_spans = newSpan;
+ newClip->m_spans = q_check_ptr((QSpan *)realloc(newClip->m_spans, newClip->allocated*2*sizeof(QSpan)));
newClip->allocated *= 2;
}
}
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index 283c442990..e0f4f6d04f 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -134,7 +134,7 @@ Q_GUI_EXPORT
#endif
QRasterPaintEngine : public QPaintEngineEx
{
- Q_DECLARE_PRIVATE(QRasterPaintEngine)
+ Q_DECLARE_SCOPED_PRIVATE(QRasterPaintEngine)
public:
QRasterPaintEngine(QPaintDevice *device);
@@ -333,8 +333,8 @@ public:
void recalculateFastImages();
QPaintDevice *device;
- QOutlineMapper *outlineMapper;
- QRasterBuffer *rasterBuffer;
+ QScopedPointer<QOutlineMapper> outlineMapper;
+ QScopedPointer<QRasterBuffer> rasterBuffer;
#if defined (Q_WS_WIN)
HDC hdc;
@@ -345,9 +345,9 @@ public:
QRect deviceRect;
QStroker basicStroker;
- QDashStroker *dashStroker;
+ QScopedPointer<QDashStroker> dashStroker;
- QT_FT_Raster *grayRaster;
+ QScopedPointer<QT_FT_Raster> grayRaster;
unsigned long rasterPoolSize;
unsigned char *rasterPoolBase;
@@ -359,7 +359,7 @@ public:
QFontEngineGlyphCache::Type glyphCacheType;
- QClipData *baseClip;
+ QScopedPointer<QClipData> baseClip;
int deviceDepth;
@@ -370,7 +370,7 @@ public:
uint isPlain45DegreeRotation : 1;
#endif
- QRasterizer *rasterizer;
+ QScopedPointer<QRasterizer> rasterizer;
};
@@ -541,7 +541,7 @@ inline const QClipData *QRasterPaintEnginePrivate::clip() const {
Q_Q(const QRasterPaintEngine);
if (q->state() && q->state()->clip && q->state()->clip->enabled)
return q->state()->clip;
- return baseClip;
+ return baseClip.data();
}
diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp
index e3248ea73c..6ab39da4ca 100644
--- a/src/gui/painting/qpaintengine_x11.cpp
+++ b/src/gui/painting/qpaintengine_x11.cpp
@@ -271,7 +271,7 @@ void QXRenderTessellator::addTrap(const Trapezoid &trap)
{
if (size == allocated) {
allocated = qMax(2*allocated, 64);
- traps = (XTrapezoid *)realloc(traps, allocated * sizeof(XTrapezoid));
+ traps = q_check_ptr((XTrapezoid *)realloc(traps, allocated * sizeof(XTrapezoid)));
}
traps[size].top = Q27Dot5ToXFixed(trap.top);
traps[size].bottom = Q27Dot5ToXFixed(trap.bottom);
diff --git a/src/gui/painting/qpaintengine_x11_p.h b/src/gui/painting/qpaintengine_x11_p.h
index 738a155066..2a7894d5c5 100644
--- a/src/gui/painting/qpaintengine_x11_p.h
+++ b/src/gui/painting/qpaintengine_x11_p.h
@@ -76,7 +76,7 @@ struct qt_float_point
class QX11PaintEngine : public QPaintEngine
{
- Q_DECLARE_PRIVATE(QX11PaintEngine)
+ Q_DECLARE_SCOPED_PRIVATE(QX11PaintEngine)
public:
QX11PaintEngine();
~QX11PaintEngine();
diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h
index 2a50a51e69..c38716fa66 100644
--- a/src/gui/painting/qpaintengineex_p.h
+++ b/src/gui/painting/qpaintengineex_p.h
@@ -143,7 +143,7 @@ class QPixmapFilter;
class Q_GUI_EXPORT QPaintEngineEx : public QPaintEngine
{
- Q_DECLARE_PRIVATE(QPaintEngineEx)
+ Q_DECLARE_SCOPED_PRIVATE(QPaintEngineEx)
public:
QPaintEngineEx();
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 8738f547af..5e106fbe2b 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -80,21 +80,6 @@ QT_BEGIN_NAMESPACE
bool qt_show_painter_debug_output = true;
#endif
-class QPainterPrivateCleaner
-{
-public:
- static inline void cleanup(QPainterPrivate *d)
- {
- delete d;
- }
-
- static inline void reset(QPainterPrivate *&d, QPainterPrivate *other)
- {
- delete d;
- d = other;
- }
-};
-
extern QPixmap qt_pixmapForBrush(int style, bool invert);
void qt_format_text(const QFont &font,
@@ -276,9 +261,7 @@ bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev)
// However, to support corner cases we grow the array dynamically if needed.
sp->d_ptr->d_ptrs_size <<= 1;
const int newSize = sp->d_ptr->d_ptrs_size * sizeof(QPainterPrivate *);
- QPainterPrivate ** newPointers = (QPainterPrivate **)realloc(sp->d_ptr->d_ptrs, newSize);
- Q_CHECK_PTR(newPointers);
- sp->d_ptr->d_ptrs = newPointers;
+ sp->d_ptr->d_ptrs = q_check_ptr((QPainterPrivate **)realloc(sp->d_ptr->d_ptrs, newSize));
}
sp->d_ptr->d_ptrs[++sp->d_ptr->refcount - 2] = q->d_ptr.data();
q->d_ptr.data_ptr() = sp->d_ptr.data();
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index c81f5d472e..227c6f5506 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -79,11 +79,11 @@ class QTextItem;
class QMatrix;
class QTransform;
-class QPainterPrivateCleaner;
+class QPainterPrivateDeleter;
class Q_GUI_EXPORT QPainter
{
- Q_DECLARE_PRIVATE(QPainter)
+ Q_DECLARE_SCOPED_PRIVATE(QPainter)
Q_GADGET
Q_FLAGS(RenderHint RenderHints)
@@ -500,7 +500,7 @@ private:
Q_DISABLE_COPY(QPainter)
friend class Q3Painter;
- QScopedCustomPointer<QPainterPrivate, QPainterPrivateCleaner> d_ptr;
+ QCustomScopedPointer<QPainterPrivate> d_ptr;
friend class QFontEngine;
friend class QFontEngineBox;
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index ec8a46ce7b..713cb146f7 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -73,7 +73,7 @@
QT_BEGIN_NAMESPACE
-struct QPainterPathPrivateHandler
+struct QPainterPathPrivateDeleter
{
static inline void cleanup(QPainterPathPrivate *d)
{
@@ -82,13 +82,6 @@ struct QPainterPathPrivateHandler
if (d && !d->ref.deref())
delete static_cast<QPainterPathData *>(d);
}
-
- static inline void reset(QPainterPathPrivate *&d, QPainterPathPrivate *other)
- {
- QPainterPathPrivate *oldD = d;
- d = other;
- cleanup(oldD);
- }
};
// This value is used to determine the length of control point vectors
diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h
index 5068739e79..ef92397f51 100644
--- a/src/gui/painting/qpainterpath.h
+++ b/src/gui/painting/qpainterpath.h
@@ -57,7 +57,7 @@ QT_MODULE(Gui)
class QFont;
class QPainterPathPrivate;
-struct QPainterPathPrivateHandler;
+struct QPainterPathPrivateDeleter;
class QPainterPathData;
class QPainterPathStrokerPrivate;
class QPolygonF;
@@ -203,7 +203,7 @@ public:
QPainterPath &operator-=(const QPainterPath &other);
private:
- QScopedCustomPointer<QPainterPathPrivate, QPainterPathPrivateHandler> d_ptr;
+ QScopedPointer<QPainterPathPrivate, QPainterPathPrivateDeleter> d_ptr;
inline void ensureData() { if (!d_ptr) ensureData_helper(); }
void ensureData_helper();
@@ -237,7 +237,7 @@ public:
friend class QPainterPathStrokerPrivate;
friend class QMatrix;
friend class QTransform;
- friend struct QPainterPathPrivateHandler;
+ friend struct QPainterPathPrivateDeleter;
#ifndef QT_NO_DATASTREAM
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &);
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &);
@@ -256,7 +256,7 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &);
class Q_GUI_EXPORT QPainterPathStroker
{
- Q_DECLARE_PRIVATE(QPainterPathStroker)
+ Q_DECLARE_SCOPED_PRIVATE(QPainterPathStroker)
public:
QPainterPathStroker();
~QPainterPathStroker();
diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h
index 0e023d6b06..26f5bd7f56 100644
--- a/src/gui/painting/qpdf_p.h
+++ b/src/gui/painting/qpdf_p.h
@@ -183,7 +183,7 @@ class QPdfBaseEnginePrivate;
class QPdfBaseEngine : public QAlphaPaintEngine, public QPrintEngine
{
- Q_DECLARE_PRIVATE(QPdfBaseEngine)
+ Q_DECLARE_SCOPED_PRIVATE(QPdfBaseEngine)
public:
QPdfBaseEngine(QPdfBaseEnginePrivate &d, PaintEngineFeatures f);
~QPdfBaseEngine() {}
diff --git a/src/gui/painting/qprintengine_mac_p.h b/src/gui/painting/qprintengine_mac_p.h
index 23e99cd592..1fdb17248c 100644
--- a/src/gui/painting/qprintengine_mac_p.h
+++ b/src/gui/painting/qprintengine_mac_p.h
@@ -72,7 +72,7 @@ class QPrinterPrivate;
class QMacPrintEnginePrivate;
class QMacPrintEngine : public QPaintEngine, public QPrintEngine
{
- Q_DECLARE_PRIVATE(QMacPrintEngine)
+ Q_DECLARE_SCOPED_PRIVATE(QMacPrintEngine)
public:
QMacPrintEngine(QPrinter::PrinterMode mode);
diff --git a/src/gui/painting/qprintengine_pdf_p.h b/src/gui/painting/qprintengine_pdf_p.h
index 6f884a9535..e130ada8f9 100644
--- a/src/gui/painting/qprintengine_pdf_p.h
+++ b/src/gui/painting/qprintengine_pdf_p.h
@@ -84,7 +84,7 @@ class QPdfEnginePrivate;
class QPdfEngine : public QPdfBaseEngine
{
- Q_DECLARE_PRIVATE(QPdfEngine)
+ Q_DECLARE_SCOPED_PRIVATE(QPdfEngine)
public:
QPdfEngine(QPrinter::PrinterMode m);
virtual ~QPdfEngine();
diff --git a/src/gui/painting/qprintengine_ps_p.h b/src/gui/painting/qprintengine_ps_p.h
index 986be38a64..4b8034e37b 100644
--- a/src/gui/painting/qprintengine_ps_p.h
+++ b/src/gui/painting/qprintengine_ps_p.h
@@ -70,7 +70,7 @@ class QPSPrintEnginePrivate;
class QPSPrintEngine : public QPdfBaseEngine
{
- Q_DECLARE_PRIVATE(QPSPrintEngine)
+ Q_DECLARE_SCOPED_PRIVATE(QPSPrintEngine)
public:
// QPrinter uses these
explicit QPSPrintEngine(QPrinter::PrinterMode m);
diff --git a/src/gui/painting/qprintengine_qws_p.h b/src/gui/painting/qprintengine_qws_p.h
index 41cf935e48..5e552feee1 100644
--- a/src/gui/painting/qprintengine_qws_p.h
+++ b/src/gui/painting/qprintengine_qws_p.h
@@ -70,7 +70,7 @@ class QImage;
class QtopiaPrintEngine : public QPaintEngine, public QPrintEngine
{
- Q_DECLARE_PRIVATE(QtopiaPrintEngine)
+ Q_DECLARE_SCOPED_PRIVATE(QtopiaPrintEngine)
public:
QtopiaPrintEngine(QPrinter::PrinterMode mode);
diff --git a/src/gui/painting/qprintengine_win_p.h b/src/gui/painting/qprintengine_win_p.h
index 9eb0b69c6b..4438ce74b4 100644
--- a/src/gui/painting/qprintengine_win_p.h
+++ b/src/gui/painting/qprintengine_win_p.h
@@ -69,7 +69,7 @@ class QPainterState;
class QWin32PrintEngine : public QAlphaPaintEngine, public QPrintEngine
{
- Q_DECLARE_PRIVATE(QWin32PrintEngine)
+ Q_DECLARE_SCOPED_PRIVATE(QWin32PrintEngine)
public:
QWin32PrintEngine(QPrinter::PrinterMode mode);
diff --git a/src/gui/painting/qprinter.h b/src/gui/painting/qprinter.h
index 25c2f0c738..842845b7c1 100644
--- a/src/gui/painting/qprinter.h
+++ b/src/gui/painting/qprinter.h
@@ -65,7 +65,7 @@ class QPrinterInfo;
class Q_GUI_EXPORT QPrinter : public QPaintDevice
{
- Q_DECLARE_PRIVATE(QPrinter)
+ Q_DECLARE_SCOPED_PRIVATE(QPrinter)
public:
enum PrinterMode { ScreenResolution, PrinterResolution, HighResolution };
diff --git a/src/gui/painting/qprinterinfo.h b/src/gui/painting/qprinterinfo.h
index c34e59173e..5c0a25fd8b 100644
--- a/src/gui/painting/qprinterinfo.h
+++ b/src/gui/painting/qprinterinfo.h
@@ -53,10 +53,10 @@ QT_MODULE(Gui)
#ifndef QT_NO_PRINTER
class QPrinterInfoPrivate;
-class QPrinterInfoPrivateCleanup;
+class QPrinterInfoPrivateDeleter;
class Q_GUI_EXPORT QPrinterInfo
{
-Q_DECLARE_PRIVATE(QPrinterInfo)
+Q_DECLARE_SCOPED_PRIVATE(QPrinterInfo)
public:
QPrinterInfo();
@@ -77,7 +77,7 @@ public:
private:
QPrinterInfo(const QString& name);
- QScopedCustomPointer<QPrinterInfoPrivate, QPrinterInfoPrivateCleanup> d_ptr;
+ QScopedPointer<QPrinterInfoPrivate, QPrinterInfoPrivateDeleter> d_ptr;
};
#endif // QT_NO_PRINTER
diff --git a/src/gui/painting/qprinterinfo_mac.cpp b/src/gui/painting/qprinterinfo_mac.cpp
index 69320158ae..66455d911c 100644
--- a/src/gui/painting/qprinterinfo_mac.cpp
+++ b/src/gui/painting/qprinterinfo_mac.cpp
@@ -65,7 +65,7 @@ private:
static QPrinterInfoPrivate nullQPrinterInfoPrivate;
-class QPrinterInfoPrivateCleanup
+class QPrinterInfoPrivateDeleter
{
public:
static inline void cleanup(QPrinterInfoPrivate *d)
@@ -73,12 +73,6 @@ public:
if (d != &nullQPrinterInfoPrivate)
delete d;
}
-
- static inline void reset(QPrinterInfoPrivate *&d, QPrinterInfoPrivate *other)
- {
- cleanup(d);
- d = other;
- }
};
extern QPrinter::PaperSize qSizeFTopaperSize(const QSizeF& size);
diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp
index b9f1f3b626..11f94dc3e3 100644
--- a/src/gui/painting/qprinterinfo_unix.cpp
+++ b/src/gui/painting/qprinterinfo_unix.cpp
@@ -82,7 +82,7 @@ private:
static QPrinterInfoPrivate nullQPrinterInfoPrivate;
-class QPrinterInfoPrivateCleanup
+class QPrinterInfoPrivateDeleter
{
public:
static inline void cleanup(QPrinterInfoPrivate *d)
@@ -90,12 +90,6 @@ public:
if (d != &nullQPrinterInfoPrivate)
delete d;
}
-
- static inline void reset(QPrinterInfoPrivate *&d, QPrinterInfoPrivate *other)
- {
- cleanup(d);
- d = other;
- }
};
/////////////////////////////////////////////////////////////////////////////
diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp
index e047f5de9e..3f2c5104c0 100644
--- a/src/gui/painting/qprinterinfo_win.cpp
+++ b/src/gui/painting/qprinterinfo_win.cpp
@@ -69,7 +69,7 @@ private:
static QPrinterInfoPrivate nullQPrinterInfoPrivate;
-class QPrinterInfoPrivateCleanup
+class QPrinterInfoPrivateDeleter
{
public:
static inline void cleanup(QPrinterInfoPrivate *d)
@@ -77,12 +77,6 @@ public:
if (d != &nullQPrinterInfoPrivate)
delete d;
}
-
- static inline void reset(QPrinterInfoPrivate *&d, QPrinterInfoPrivate *other)
- {
- cleanup(d);
- d = other;
- }
};
/////////////////////////////////////////////////////////////////////////////
diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp
index 6d1527130f..346b31dc15 100644
--- a/src/gui/painting/qrasterizer.cpp
+++ b/src/gui/painting/qrasterizer.cpp
@@ -437,10 +437,8 @@ inline void QScanConverter::allocate(int size)
{
if (m_alloc < size) {
int newAlloc = qMax(size, 2 * m_alloc);
- Intersection *newIntersections = (Intersection *)realloc(m_intersections, newAlloc * sizeof(Intersection));
- Q_CHECK_PTR(newIntersections);
+ m_intersections = q_check_ptr((Intersection *)realloc(m_intersections, newAlloc * sizeof(Intersection)));
m_alloc = newAlloc;
- m_intersections = newIntersections;
}
}
diff --git a/src/gui/painting/qtessellator.cpp b/src/gui/painting/qtessellator.cpp
index 711f99701c..6c16772f71 100644
--- a/src/gui/painting/qtessellator.cpp
+++ b/src/gui/painting/qtessellator.cpp
@@ -406,9 +406,9 @@ void QTessellatorPrivate::Scanline::init(int maxActiveEdges)
if (!edges || maxActiveEdges > default_alloc) {
max_edges = maxActiveEdges;
int s = qMax(maxActiveEdges + 1, default_alloc + 1);
- edges = (Edge **)realloc(edges, s*sizeof(Edge *));
- edge_table = (Edge *)realloc(edge_table, s*sizeof(Edge));
- old = (Edge **)realloc(old, s*sizeof(Edge *));
+ edges = q_check_ptr((Edge **)realloc(edges, s*sizeof(Edge *)));
+ edge_table = q_check_ptr((Edge *)realloc(edge_table, s*sizeof(Edge)));
+ old = q_check_ptr((Edge **)realloc(old, s*sizeof(Edge *)));
}
size = 0;
old_size = 0;
@@ -566,8 +566,8 @@ void QTessellatorPrivate::Vertices::init(int maxVertices)
{
if (!storage || maxVertices > allocated) {
int size = qMax((int)default_alloc, maxVertices);
- storage = (Vertex *)realloc(storage, size*sizeof(Vertex));
- sorted = (Vertex **)realloc(sorted, size*sizeof(Vertex *));
+ storage = q_check_ptr((Vertex *)realloc(storage, size*sizeof(Vertex)));
+ sorted = q_check_ptr((Vertex **)realloc(sorted, size*sizeof(Vertex *)));
allocated = maxVertices;
}
}
@@ -739,7 +739,7 @@ void QTessellatorPrivate::cancelCoincidingEdges()
if (testListSize > tlSize - 2) {
tlSize = qMax(tlSize*2, 16);
- tl = (QCoincidingEdge *)realloc(tl, tlSize*sizeof(QCoincidingEdge));
+ tl = q_check_ptr((QCoincidingEdge *)realloc(tl, tlSize*sizeof(QCoincidingEdge)));
}
if (n->flags & (LineBeforeStarts|LineBeforeHorizontal)) {
tl[testListSize].start = n;
diff --git a/src/gui/painting/qwindowsurface_raster_p.h b/src/gui/painting/qwindowsurface_raster_p.h
index 0f02a45ec7..1b09914d7f 100644
--- a/src/gui/painting/qwindowsurface_raster_p.h
+++ b/src/gui/painting/qwindowsurface_raster_p.h
@@ -111,7 +111,7 @@ public:
private:
void prepareBuffer(QImage::Format format, QWidget *widget);
- Q_DECLARE_PRIVATE(QRasterWindowSurface)
+ Q_DECLARE_SCOPED_PRIVATE(QRasterWindowSurface)
QScopedPointer<QRasterWindowSurfacePrivate> d_ptr;
};
diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp
index e81adccb91..5de4317bdd 100644
--- a/src/gui/painting/qwindowsurface_s60.cpp
+++ b/src/gui/painting/qwindowsurface_s60.cpp
@@ -75,8 +75,8 @@ QS60WindowSurface::QS60WindowSurface(QWidget* widget)
// We create empty CFbsBitmap here -> it will be resized in setGeometry
- d_ptr->bitmap = new (ELeave) CFbsBitmap;
- User::LeaveIfError( d_ptr->bitmap->Create(TSize(0, 0), mode ) );
+ d_ptr->bitmap = q_check_ptr(new CFbsBitmap); // CBase derived object needs check on new
+ qt_throwIfError( d_ptr->bitmap->Create(TSize(0, 0), mode ) );
updatePaintDeviceOnBitmap();
@@ -141,7 +141,8 @@ bool QS60WindowSurface::scroll(const QRegion &area, int dx, int dy)
if (d_ptr->device.isNull())
return false;
- CFbsBitmapDevice *bitmapDevice = CFbsBitmapDevice::NewL(d_ptr->bitmap);
+ CFbsBitmapDevice *bitmapDevice = 0;
+ QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(d_ptr->bitmap));
CBitmapContext *bitmapContext;
TInt err = bitmapDevice->CreateBitmapContext(bitmapContext);
if (err != KErrNone) {
@@ -177,7 +178,7 @@ void QS60WindowSurface::setGeometry(const QRect& rect)
QWindowSurface::setGeometry(rect);
TRect nativeRect(qt_QRect2TRect(rect));
- User::LeaveIfError(d_ptr->bitmap->Resize(nativeRect.Size()));
+ qt_throwIfError(d_ptr->bitmap->Resize(nativeRect.Size()));
if (!rect.isNull())
updatePaintDeviceOnBitmap();