From 1f75d202bef3f3a56edcfaf7f72f76bcabe168fa Mon Sep 17 00:00:00 2001 From: zhangtingan Date: Mon, 24 Aug 2026 02:21:41 +0800 Subject: [PATCH] fix(#266113): distinguish wrong-password retry text in RAR5 password dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RAR5 wrong password走 else 分支 emit error + return true 不终止进程, unrar 再次输出密码提示导致 ET_WrongPassword 被覆盖为 ET_NeedPassword → ET_NoError,错误上下文丢失。首问与重试复用同一 PasswordNeededQuery、 同一写死文案「此文件已加密」,瞬时错误提示被对话框掩盖。 修复方向①(最小侵入):新增 m_bWrongPasswordRetry 标记,在 RAR5 else 分支 设为 true,handlePassword 重弹密码框时传入该标记,PasswordNeededQuery 据 此显示「密码错误,请重新输入解压密码」而非「此文件已加密」。标记在每次 handlePassword 后重置。 不破坏 ET_MissingVolume 豁免,不影响 RAR4/ZIP/7z 现有逻辑。 --- 3rdparty/clirarplugin/clirarplugin.cpp | 1 + 3rdparty/interface/archiveinterface/cliinterface.cpp | 3 ++- 3rdparty/interface/archiveinterface/cliinterface.h | 1 + 3rdparty/interface/queries.cpp | 9 +++++++-- 3rdparty/interface/queries.h | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/3rdparty/clirarplugin/clirarplugin.cpp b/3rdparty/clirarplugin/clirarplugin.cpp index a991a33c9..282696a1c 100644 --- a/3rdparty/clirarplugin/clirarplugin.cpp +++ b/3rdparty/clirarplugin/clirarplugin.cpp @@ -292,6 +292,7 @@ bool CliRarPlugin::handleLine(const QString &line, WorkType workStatus) return false; } else { // RAR5密码错误:发送错误提示但不中断进程,允许用户重新输入密码 emit error(tr("Wrong password"), tr("The password entered is incorrect. Please try again.")); + m_bWrongPasswordRetry = true; // 标记下次重弹密码框时使用「密码错误」文案 return true; } } diff --git a/3rdparty/interface/archiveinterface/cliinterface.cpp b/3rdparty/interface/archiveinterface/cliinterface.cpp index cd4cdbbe5..67ba78b54 100644 --- a/3rdparty/interface/archiveinterface/cliinterface.cpp +++ b/3rdparty/interface/archiveinterface/cliinterface.cpp @@ -1061,7 +1061,8 @@ PluginFinishType CliInterface::handlePassword() } } - PasswordNeededQuery query(name); + PasswordNeededQuery query(name, m_bWrongPasswordRetry); + m_bWrongPasswordRetry = false; emit signalQuery(&query); query.waitForResponse(); diff --git a/3rdparty/interface/archiveinterface/cliinterface.h b/3rdparty/interface/archiveinterface/cliinterface.h index 01b3f3ba1..65899ed66 100644 --- a/3rdparty/interface/archiveinterface/cliinterface.h +++ b/3rdparty/interface/archiveinterface/cliinterface.h @@ -285,6 +285,7 @@ private slots: bool m_isProcessKilled = false; // 进程已经结束 bool m_isEmptyArchive = false; // 压缩包内无数据 bool m_isCorruptArchive = false; // 是否非致命错误 + bool m_bWrongPasswordRetry = false; // 密码错误后重弹密码框标记,供 handlePassword 区分重试文案 private: QList m_files; // 文件 diff --git a/3rdparty/interface/queries.cpp b/3rdparty/interface/queries.cpp index d4302e73e..78f94dced 100644 --- a/3rdparty/interface/queries.cpp +++ b/3rdparty/interface/queries.cpp @@ -332,10 +332,11 @@ void OverwriteQuery::setWidgetType(QWidget *pWgt, DPalette::ColorType ct, double -PasswordNeededQuery::PasswordNeededQuery(const QString &strFileName, QObject *parent) +PasswordNeededQuery::PasswordNeededQuery(const QString &strFileName, bool bWrongPassword, QObject *parent) : Query(parent) { m_data[QStringLiteral("fileName")] = strFileName; + m_data[QStringLiteral("wrongPassword")] = bWrongPassword; } PasswordNeededQuery::~PasswordNeededQuery() @@ -376,7 +377,11 @@ void PasswordNeededQuery::execute() pTipLbl->setForegroundRole(DPalette::WindowText); // pTipLbl->setWordWrap(true); DFontSizeManager::instance()->bind(pTipLbl, DFontSizeManager::T6, QFont::Normal); - pTipLbl->setText(tr("Encrypted file, please enter the password")); + if (m_data.value(QStringLiteral("wrongPassword")).toBool()) { + pTipLbl->setText(tr("Wrong password, please re-enter the password")); + } else { + pTipLbl->setText(tr("Encrypted file, please enter the password")); + } pTipLbl->setAlignment(Qt::AlignCenter); m_strDesText = pTipLbl->text(); diff --git a/3rdparty/interface/queries.h b/3rdparty/interface/queries.h index e39c80b86..cb8f09119 100644 --- a/3rdparty/interface/queries.h +++ b/3rdparty/interface/queries.h @@ -194,7 +194,7 @@ class PasswordNeededQuery : public Query * @param strFileName 文件名(含路径) * @param parent */ - explicit PasswordNeededQuery(const QString &strFileName, QObject *parent = nullptr); + explicit PasswordNeededQuery(const QString &strFileName, bool bWrongPassword = false, QObject *parent = nullptr); ~PasswordNeededQuery() override; /**