* silence warnings with null QPixmap

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23106 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stefan Schimanski 2008-02-21 19:43:53 +00:00
parent 833f0bab52
commit c885205620

View File

@ -53,14 +53,16 @@ protected:
QStyleOptionViewItemV3 opt = setOptions(index, option); QStyleOptionViewItemV3 opt = setOptions(index, option);
QVariant value = index.data(Qt::DisplayRole); QVariant value = index.data(Qt::DisplayRole);
QPixmap pixmap = qvariant_cast<QPixmap>(value); QPixmap pixmap = qvariant_cast<QPixmap>(value);
const QSize size = pixmap.size();
// draw // draw
painter->save(); painter->save();
drawBackground(painter, opt, index); drawBackground(painter, opt, index);
painter->drawPixmap(option.rect.left() + (16 - size.width()) / 2, if (!pixmap.isNull()) {
option.rect.top() + (option.rect.height() - size.height()) / 2, const QSize size = pixmap.size();
pixmap); painter->drawPixmap(option.rect.left() + (16 - size.width()) / 2,
option.rect.top() + (option.rect.height() - size.height()) / 2,
pixmap);
}
drawFocus(painter, opt, option.rect); drawFocus(painter, opt, option.rect);
painter->restore(); painter->restore();
} }
@ -107,10 +109,13 @@ public:
if (!QPixmapCache::find("completion" + name, scaled)) { if (!QPixmapCache::find("completion" + name, scaled)) {
// load icon from disk // load icon from disk
QPixmap p = QPixmap(name); QPixmap p = QPixmap(name);
if (!p.isNull()) {
// scale it to 16x16 or smaller
scaled
= p.scaled(min(16, p.width()), min(16, p.height()),
Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
// scale it to 16x16 or smaller
scaled = p.scaled(min(16, p.width()), min(16, p.height()),
Qt::KeepAspectRatio, Qt::SmoothTransformation);
QPixmapCache::insert("completion" + name, scaled); QPixmapCache::insert("completion" + name, scaled);
} }
return scaled; return scaled;