All pastes #763418 Raw Edit

Mem leak - log and code

public text v1 · immutable
·published 2007-11-06 13:16 UTC
rendered paste body
==21966== 5,600 (544 direct, 5,056 indirect) bytes in 2 blocks are definitely lost in loss record 190 of 334
==21966==    at 0x4021DC5: operator new(unsigned) (vg_replace_malloc.c:163)
==21966==    by 0x6240CEA: QX11PaintEngine::QX11PaintEngine() (qpaintengine_x11.cpp:425)
==21966==    by 0x6180CA2: QPixmap::paintEngine() const (qpixmap_x11.cpp:2159)
==21966==    by 0x61B850E: QPainter::begin(QPaintDevice*) (qpainter.cpp:1303)
==21966==    by 0x61B8CDF: QPainter::QPainter(QPaintDevice*) (qpainter.cpp:1072)
==21966==    by 0x46485EB: KMail::HeaderItem::pixmapMerge(QList<QPixmap>) const (headeritem.cpp:218)
==21966==    by 0x4648B40: KMail::HeaderItem::pixmap(int) const (headeritem.cpp:331)
==21966==    by 0x6887697: Q3ListViewItem::paintCell(QPainter*, QColorGroup const&, int, int, int) (q3listview.cpp:2091)
==21966==    by 0x5C345FE: K3ListViewItem::paintCell(QPainter*, QColorGroup const&, int, int, int) (k3listview.cpp:2346)
==21966==    by 0x4648401: KMail::HeaderItem::paintCell(QPainter*, QColorGroup const&, int, int, int) (headeritem.cpp:440)
==21966==    by 0x6885542: Q3ListView::drawContentsOffset(QPainter*, int, int, int, int, int, int) (q3listview.cpp:2896)
==21966==    by 0x68ECAD6: Q3ScrollView::viewportPaintEvent(QPaintEvent*) (q3scrollview.cpp:1735)


QPixmap HeaderItem::pixmapMerge( PixmapList pixmaps ) const
{
  // Calculate the width and height of the resulting pixmap
  int width = 0;
  int height = 0;
  for ( PixmapList::ConstIterator it = pixmaps.begin();
      it != pixmaps.end(); ++it ) {
    width += (*it).width();
    height = qMax( height, (*it).height() );
  }

  QPixmap res( width, height );
  QBitmap mask( width, height );
  QPainter resultPainter( &res );
  QPainter maskPainter( &mask );
  mask.clear();

  // Paint all pixmaps of the list to the resulting pixmap
  int x = 0;
  for ( PixmapList::ConstIterator it = pixmaps.begin();
      it != pixmaps.end(); ++it ) {
    resultPainter.drawPixmap( x, ( height - (*it).height() ) / 2, *it );
    maskPainter.drawPixmap( x, (height - (*it).height()) / 2, (*it).mask() );
    x += (*it).width();
  }

  resultPainter.end();
  maskPainter.end();
  res.setMask( mask );
  return res;
}