crash if appitem icon is null

Change-Id: If3598182494efaf29b5d1714a5bc1a1ee3a20703
This commit is contained in:
石博文 2017-06-16 09:00:53 +08:00
parent a5b044e585
commit 3428c67280
Notes: Deepin Code Review 2017-06-16 09:03:17 +08:00
Code-Review+2: 石博文 <sbw@sbw.so>
Verified+1: 石博文 <sbw@sbw.so>
Submitted-by: 石博文 <sbw@sbw.so>
Submitted-at: Fri, 16 Jun 2017 09:03:14 +0800
Reviewed-on: https://cr.deepin.io/23868
Project: dde/dde-dock
Branch: refs/heads/master
2 changed files with 15 additions and 8 deletions

View File

@ -36,6 +36,10 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
m_itemScene(new QGraphicsScene(this)),
m_draging(false),
m_smallIcon(QPixmap()),
m_largeIcon(QPixmap()),
m_horizontalIndicator(QPixmap(":/indicator/resources/indicator.png")),
m_verticalIndicator(QPixmap(":/indicator/resources/indicator_ver.png")),
m_activeHorizontalIndicator(QPixmap(":/indicator/resources/indicator_active.png")),
@ -251,8 +255,11 @@ void AppItem::paintEvent(QPaintEvent *e)
// icon
const QPixmap pixmap = DockDisplayMode == Efficient ? m_smallIcon : m_largeIcon;
if (pixmap.isNull())
return;
// icon pos
QPointF iconPos = itemRect.center() - QRectF(pixmap.rect()).center();
const QPointF iconPos = itemRect.center() - QRectF(pixmap.rect()).center();
// draw ligher/normal icon
if (!m_hover)

View File

@ -14,18 +14,18 @@ class WiredItem : public DeviceItem
public:
explicit WiredItem(const QUuid &deviceUuid);
NetworkDevice::NetworkType type() const;
NetworkDevice::NetworkState state() const;
QWidget *itemPopup();
NetworkDevice::NetworkType type() const override;
NetworkDevice::NetworkState state() const override;
QWidget *itemPopup() override;
const QString itemCommand() const override;
protected:
void paintEvent(QPaintEvent *e);
void resizeEvent(QResizeEvent *e);
void mousePressEvent(QMouseEvent *e);
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
private slots:
void refreshIcon();
void refreshIcon() override;
void reloadIcon();
void activeConnectionChanged(const QUuid &uuid);
void deviceStateChanged(const NetworkDevice &device);