Skip to content

fix: clear password input undo history#70

Merged
robertkill merged 1 commit into
linuxdeepin:masterfrom
robertkill:fix/task-392179-clear-password-history
Jun 30, 2026
Merged

fix: clear password input undo history#70
robertkill merged 1 commit into
linuxdeepin:masterfrom
robertkill:fix/task-392179-clear-password-history

Conversation

@robertkill

@robertkill robertkill commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

fix: clear password input undo history
Use setText(QString()) instead of clear() when resetting password inputs so Qt clears the line edit undo history and previous passwords cannot be restored by undo after echo mode changes.

pms:TASK-392179

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @robertkill, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@robertkill robertkill force-pushed the fix/task-392179-clear-password-history branch from 6f0da1b to 58cfae8 Compare June 30, 2026 09:09
deepin-ci-robot added a commit to linuxdeepin/dde-session-shell-snipe that referenced this pull request Jun 30, 2026
Synchronize source files from linuxdeepin/dde-session-shell.

Source-pull-request: linuxdeepin/dde-session-shell#70
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:85分(0-100之间的整数)

■ 【总体评价】

代码将多处QLineEdit的clear方法替换为等价的setText(QString()),功能无变化但降低了可读性
逻辑正确但因代码冗余和可读性下降扣15分

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

QLineEdit::clear()与setText(QString())在Qt底层实现完全等价,均会清空文本、重置光标和修改状态,在lightergreeter.cpp和auth_*.cpp中的替换后语法和逻辑无错误
潜在问题:无
建议:保持现有逻辑即可

  • 2.代码质量(较差)✕

原有的clear()方法语义明确,直接表达了清空输入框的意图,替换为setText(QString())增加了理解成本,且在多个文件的reset()、setAuthState()等函数中重复修改缺乏必要性说明和注释
潜在问题:代码冗余导致可读性下降;缺乏修改原因注释导致后续维护困难
建议:回退至使用clear()方法;若因特殊框架要求必须使用setText,需在提交信息或代码注释中明确说明原因

  • 3.代码性能(无性能问题)✓

两种写法底层均触发相同的文本设置与界面重绘流程,无额外内存分配或计算开销
建议:无

  • 4.代码安全(存在 0 个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
代码仅涉及UI控件的文本清空操作,不涉及外部输入处理、内存越界、命令执行等安全风险面

  • 建议:无

■ 【改进建议代码示例】

diff --git a/src/session-widgets/auth_password.cpp b/src/session-widgets/auth_password.cpp
index 5de5d39d..cee0e131 100644
--- a/src/session-widgets/auth_password.cpp
+++ b/src/session-widgets/auth_password.cpp
@@ -318,7 +318,7 @@ void AuthPassword::initConnections()
  */
 void AuthPassword::reset()
 {
-    m_lineEdit->setText(QString());
+    m_lineEdit->clear();
     m_lineEdit->setAlert(false);
     m_lineEdit->hideAlertMessage();
     setFocusProxy(m_lineEdit);
@@ -348,7 +348,7 @@ void AuthPassword::setAuthState(const AuthState state, const QString &result)
         setAnimationState(false);
         setAuthStateStyle(LOGIN_CHECK);
         m_lineEdit->setAlert(false);
-        m_lineEdit->setText(QString());
+        m_lineEdit->clear();
         setLineEditEnabled(false);
         setLineEditInfo(tr("Verification successful"), PlaceHolderText);
         m_showPrompt = true;

Comment thread lighter-greeter/lightergreeter.cpp
18202781743
18202781743 previously approved these changes Jun 30, 2026
Use setText(QString()) instead of clear() when resetting password inputs so Qt clears the line edit undo history and previous passwords cannot be restored by undo after echo mode changes.

pms:TASK-392179
@robertkill robertkill force-pushed the fix/task-392179-clear-password-history branch from 58cfae8 to 94ad1a0 Compare June 30, 2026 09:24
deepin-ci-robot added a commit to linuxdeepin/dde-session-shell-snipe that referenced this pull request Jun 30, 2026
Synchronize source files from linuxdeepin/dde-session-shell.

Source-pull-request: linuxdeepin/dde-session-shell#70
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, robertkill

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@robertkill robertkill merged commit af77898 into linuxdeepin:master Jun 30, 2026
15 of 17 checks passed
robertkill pushed a commit to linuxdeepin/dde-session-shell-snipe that referenced this pull request Jun 30, 2026
Synchronize source files from linuxdeepin/dde-session-shell.

Source-pull-request: linuxdeepin/dde-session-shell#70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants