fix: 解决任务栏在预览关闭时崩溃问题

1.通过略缩图关闭驻留应用,任务栏崩溃.由于使用了野指针,导致概率性崩溃。
2.非驻留时,关闭最后一个预览时AppItem对象被析构,但是之前connect没有指定receiver。导致信号还是被响应,使用了野指针。

Log: 修复任务栏在缩略图状态下关闭应用崩溃问题
Bug: https://pms.uniontech.com/zentao/bug-view-89275.html
Change-Id: Ib652beb4698193c33df9ed465cf843ceefeaa6ec
This commit is contained in:
yanghongwei 2021-07-29 15:34:24 +08:00
parent 33feba31e1
commit 3960e7b359
2 changed files with 7 additions and 4 deletions

View File

@ -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);
}

View File

@ -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());