mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix set a invalid system_tray pointer as active sysTrayWidget
Change-Id: Ie31034cf314a65fe7741923565713cb5aabd30bf
This commit is contained in:
parent
f3f2d04552
commit
d5d01755ee
Notes:
Deepin Code Review
2017-11-24 11:43:49 +08:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Fri, 24 Nov 2017 11:43:48 +0800 Reviewed-on: https://cr.deepin.io/28845 Project: dde/dde-dock Branch: refs/heads/master
@ -56,7 +56,7 @@ void FashionTrayItem::setMouseEnable(const bool enable)
|
||||
|
||||
void FashionTrayItem::setActiveTray(TrayWidget *tray)
|
||||
{
|
||||
if (m_activeTray)
|
||||
if (!m_activeTray.isNull())
|
||||
{
|
||||
m_activeTray->setActive(false);
|
||||
disconnect(m_activeTray, &TrayWidget::iconChanged, this, static_cast<void (FashionTrayItem::*)()>(&FashionTrayItem::update));
|
||||
|
@ -23,6 +23,7 @@
|
||||
#define FASHIONTRAYITEM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPointer>
|
||||
|
||||
#include <traywidget.h>
|
||||
|
||||
@ -51,7 +52,7 @@ private:
|
||||
private:
|
||||
bool m_enableMouseEvent;
|
||||
|
||||
TrayWidget *m_activeTray;
|
||||
QPointer<TrayWidget> m_activeTray;
|
||||
|
||||
QPixmap m_backgroundPixmap;
|
||||
QPoint m_pressPoint;
|
||||
|
@ -75,13 +75,7 @@ void SystemTrayPlugin::displayModeChanged(const Dock::DisplayMode mode)
|
||||
QWidget *SystemTrayPlugin::itemWidget(const QString &itemKey)
|
||||
{
|
||||
if (itemKey == FASHION_MODE_ITEM)
|
||||
{
|
||||
// refresh active tray
|
||||
if (!m_fashionItem->activeTray())
|
||||
m_fashionItem->setActiveTray(m_trayList.first());
|
||||
|
||||
return m_fashionItem;
|
||||
}
|
||||
|
||||
const quint32 trayWinId = itemKey.toUInt();
|
||||
|
||||
@ -194,6 +188,8 @@ void SystemTrayPlugin::trayAdded(const quint32 winId)
|
||||
m_trayList[winId] = trayWidget;
|
||||
|
||||
m_fashionItem->setMouseEnable(m_trayList.size() == 1);
|
||||
if (!m_fashionItem->activeTray())
|
||||
m_fashionItem->setActiveTray(trayWidget);
|
||||
|
||||
if (displayMode() == Dock::Efficient)
|
||||
m_proxyInter->itemAdded(this, QString::number(winId));
|
||||
@ -207,8 +203,8 @@ void SystemTrayPlugin::trayRemoved(const quint32 winId)
|
||||
return;
|
||||
|
||||
TrayWidget *widget = m_trayList[winId];
|
||||
m_proxyInter->itemRemoved(this, QString::number(winId));
|
||||
m_trayList.remove(winId);
|
||||
m_proxyInter->itemRemoved(this, QString::number(winId));
|
||||
widget->deleteLater();
|
||||
|
||||
m_fashionItem->setMouseEnable(m_trayList.size() == 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user