mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix crash if tracked window destoryed
Change-Id: I27f965e489b4763ca59c8a2c2cd313f8f77674b9
This commit is contained in:
parent
32d87ca112
commit
25ee81a6c1
Notes:
Deepin Code Review
2017-05-24 13:35:41 +08:00
Code-Review+2: 石博文 <sbw@sbw.so> Verified+1: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Wed, 24 May 2017 13:35:38 +0800 Reviewed-on: https://cr.deepin.io/23375 Project: dde/dde-dock Branch: refs/heads/master
@ -29,6 +29,9 @@ FloatingPreview::FloatingPreview(QWidget *parent)
|
||||
|
||||
void FloatingPreview::trackWindow(AppSnapshot * const snap)
|
||||
{
|
||||
if (!m_tracked.isNull())
|
||||
m_tracked->removeEventFilter(this);
|
||||
snap->installEventFilter(this);
|
||||
m_tracked = snap;
|
||||
|
||||
const QRect r = rect();
|
||||
@ -77,6 +80,14 @@ void FloatingPreview::mouseReleaseEvent(QMouseEvent *e)
|
||||
emit m_tracked->clicked(m_tracked->wid());
|
||||
}
|
||||
|
||||
bool FloatingPreview::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched == m_tracked && event->type() == QEvent::Destroy)
|
||||
hide();
|
||||
|
||||
return QWidget::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void FloatingPreview::onCloseBtnClicked()
|
||||
{
|
||||
Q_ASSERT(!m_tracked.isNull());
|
||||
|
@ -25,6 +25,7 @@ public slots:
|
||||
private:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void mouseReleaseEvent(QMouseEvent *e);
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
private slots:
|
||||
void onCloseBtnClicked();
|
||||
|
Loading…
x
Reference in New Issue
Block a user