From 281e65aabaf9d0bf06eee4423dfd53cd9e84d44c Mon Sep 17 00:00:00 2001 From: "craig.p.drummond" Date: Thu, 13 Sep 2012 15:52:44 +0000 Subject: [PATCH] Fix drawing of selection for QGtkStyle BUG:85 BUG:86 --- widgets/fancytabwidget.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/widgets/fancytabwidget.cpp b/widgets/fancytabwidget.cpp index 9f7d5dbd1..50fd47f1e 100644 --- a/widgets/fancytabwidget.cpp +++ b/widgets/fancytabwidget.cpp @@ -72,12 +72,16 @@ void FancyTabWidget::drawGtkSelection(const QStyleOptionViewItemV4 &opt, QPainte static const int constMaxDimension=32; static QCache cache(30000); + if (opt.rect.width()<2 || opt.rect.height()<2) { + return; + } + int width=qMin(constMaxDimension, opt.rect.width()); QString key=QString::number(width)+QChar(':')+QString::number(opt.rect.height()); QPixmap *pix=cache.object(key); if (!pix) { - pix=new QPixmap(opt.rect.width(), opt.rect.height()); + pix=new QPixmap(width, opt.rect.height()); QStyleOptionViewItemV4 styleOpt(opt); pix->fill(Qt::transparent); QPainter p(pix); @@ -96,9 +100,9 @@ void FancyTabWidget::drawGtkSelection(const QStyleOptionViewItemV4 &opt, QPainte int half=qMin(opt.rect.width()>>1, pix->width()>>1); painter->drawPixmap(opt.rect.x(), opt.rect.y(), pix->copy(0, 0, half, pix->height())); if ((half*2)!=opt.rect.width()) { - painter->drawTiledPixmap(opt.rect.x()+half, opt.rect.y(), (opt.rect.width()-(2*half)), opt.rect.height(), pix->copy(half-1, 0, 1, pix->height())); + painter->drawTiledPixmap(opt.rect.x()+half, opt.rect.y(), (opt.rect.width()-((2*half))), opt.rect.height(), pix->copy(half-1, 0, 1, pix->height())); } - painter->drawPixmap((opt.rect.x()+opt.rect.width()-1)-half, opt.rect.y(), pix->copy(half-1, 0, half, pix->height())); + painter->drawPixmap((opt.rect.x()+opt.rect.width())-half, opt.rect.y(), pix->copy(half, 0, half, pix->height())); } else { painter->drawPixmap(opt.rect, *pix); }