From 0a611cc928738261f59db2b844eb26b4dfadd826 Mon Sep 17 00:00:00 2001 From: gongheng Date: Wed, 29 Apr 2026 17:50:57 +0800 Subject: [PATCH] fix(tab): use Window as message parent when lacking file permission MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use Window instance instead of currentWidget as the parent for permission denied messages to prevent potential null pointer issues. 当文件无权限时,使用 Window 实例替代 currentWidget 作为消息父控件, 避免潜在的空指针问题。 Log: 修复无权限文件打开时的消息提示目标 Bug: https://pms.uniontech.com/bug-view-353539.html Influence: 修复后打开无权限文件时,权限不足提示能稳定显示,不会因 currentWidget 为空而失败。 --- src/widgets/window.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/window.cpp b/src/widgets/window.cpp index 5d9f595c..ae126539 100644 --- a/src/widgets/window.cpp +++ b/src/widgets/window.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2011 - 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2011 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -642,7 +642,7 @@ void Window::addTab(const QString &filepath, bool activeTab) QFile::Permissions permissions = file.permissions(); bool bIsRead = (permissions & QFile::ReadUser || permissions & QFile::ReadOwner || permissions & QFile::ReadOther); if (fileInfo.exists() && !bIsRead) { - DMessageManager::instance()->sendMessage(m_editorWidget->currentWidget(), QIcon(":/images/warning.svg") + DMessageManager::instance()->sendMessage(this, QIcon(":/images/warning.svg") , QString(tr("You do not have permission to open %1")).arg(filepath)); return; }