]> git.lyx.org Git - features.git/commitdiff
* silence warnings with null QPixmap
authorStefan Schimanski <sts@lyx.org>
Thu, 21 Feb 2008 19:43:53 +0000 (19:43 +0000)
committerStefan Schimanski <sts@lyx.org>
Thu, 21 Feb 2008 19:43:53 +0000 (19:43 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23106 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiCompleter.cpp

index 3e2cdcd2ae6b86f42ba21d95f87908afb22e9214..43a828bb2f6cfa32d8cce869fe23fe6e6ca26da5 100644 (file)
@@ -53,14 +53,16 @@ protected:
                QStyleOptionViewItemV3 opt = setOptions(index, option);
                QVariant value = index.data(Qt::DisplayRole);
                QPixmap pixmap = qvariant_cast<QPixmap>(value);
-               const QSize size = pixmap.size();
-
+               
                // draw
                painter->save();
                drawBackground(painter, opt, index);
-               painter->drawPixmap(option.rect.left() + (16 - size.width()) / 2,
-                       option.rect.top() + (option.rect.height() - size.height()) / 2,
-                       pixmap);
+               if (!pixmap.isNull()) {
+                       const QSize size = pixmap.size();
+                       painter->drawPixmap(option.rect.left() + (16 - size.width()) / 2,
+                               option.rect.top() + (option.rect.height() - size.height()) / 2,
+                               pixmap);
+               }
                drawFocus(painter, opt, option.rect);
                painter->restore();
        }
@@ -107,10 +109,13 @@ public:
                        if (!QPixmapCache::find("completion" + name, scaled)) {
                                // load icon from disk
                                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);
                        }
                        return scaled;