From 3960e7b359723a3ee1a3bcd0bb8a5c1dbd081365 Mon Sep 17 00:00:00 2001 From: yanghongwei Date: Thu, 29 Jul 2021 15:34:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=A0=8F=E5=9C=A8=E9=A2=84=E8=A7=88=E5=85=B3=E9=97=AD=E6=97=B6?= =?UTF-8?q?=E5=B4=A9=E6=BA=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.通过略缩图关闭驻留应用,任务栏崩溃.由于使用了野指针,导致概率性崩溃。 2.非驻留时,关闭最后一个预览时AppItem对象被析构,但是之前connect没有指定receiver。导致信号还是被响应,使用了野指针。 Log: 修复任务栏在缩略图状态下关闭应用崩溃问题 Bug: https://pms.uniontech.com/zentao/bug-view-89275.html Change-Id: Ib652beb4698193c33df9ed465cf843ceefeaa6ec --- frame/item/appitem.cpp | 6 +++--- frame/item/components/floatingpreview.cpp | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/frame/item/appitem.cpp b/frame/item/appitem.cpp index 1b0923c54..ab9270a3f 100644 --- a/frame/item/appitem.cpp +++ b/frame/item/appitem.cpp @@ -653,9 +653,9 @@ void AppItem::showPreview() connect(m_appPreviewTips, &PreviewContainer::requestHidePopup, this, &AppItem::hidePopup); connect(m_appPreviewTips, &PreviewContainer::requestCheckWindows, m_itemEntryInter, &DockEntryInter::Check); - connect(m_appPreviewTips, &PreviewContainer::requestActivateWindow, [ = ]() { m_appPreviewTips = nullptr; }); - connect(m_appPreviewTips, &PreviewContainer::requestCancelPreviewWindow, [ = ]() { m_appPreviewTips = nullptr; }); - connect(m_appPreviewTips, &PreviewContainer::requestHidePopup, [ = ]() { m_appPreviewTips = nullptr; }); + connect(m_appPreviewTips, &PreviewContainer::requestActivateWindow, this, [ = ]() { m_appPreviewTips = nullptr; }); + connect(m_appPreviewTips, &PreviewContainer::requestCancelPreviewWindow, this, [ = ]() { m_appPreviewTips = nullptr; }); + connect(m_appPreviewTips, &PreviewContainer::requestHidePopup, this, [ = ]() { m_appPreviewTips = nullptr; }); showPopupWindow(m_appPreviewTips, true); } diff --git a/frame/item/components/floatingpreview.cpp b/frame/item/components/floatingpreview.cpp index 8dcf7a09f..685a0da79 100644 --- a/frame/item/components/floatingpreview.cpp +++ b/frame/item/components/floatingpreview.cpp @@ -171,8 +171,11 @@ bool FloatingPreview::eventFilter(QObject *watched, QEvent *event) } if (watched == m_tracked) { - if (event->type() == QEvent::Destroy) + if (event->type() == QEvent::Destroy) { + // 此处需要置空,否则当Destroy事件响应结束后,会在FloatingPreview::hideEvent使用m_tracked野指针 + m_tracked = nullptr; hide(); + } if (event->type() == QEvent::Resize && m_tracked->width() == SNAP_WIDTH) setGeometry(m_tracked->geometry());