Skip to content

Conversation

@JWWTSL
Copy link
Contributor

@JWWTSL JWWTSL commented Nov 14, 2025

log: Invalid expression input causes abnormal memory display.

bug: https://pms.uniontech.com/bug-view-337825.html

Summary by Sourcery

Bug Fixes:

  • Guard MS (Memory Store) operation with a proper condition so that invalid or partial expressions are not stored

log: Invalid expression input causes abnormal memory display.

bug: https://pms.uniontech.com/bug-view-337825.html
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 14, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR refines the MS memory-store logic in BasicModule by introducing a guard that ensures only valid, calculable expressions are stored, accompanied by a clarifying comment.

Sequence diagram for MS memory-store logic update

sequenceDiagram
    participant User as actor User
    participant BasicModule
    participant ExpressionBar
    participant InputEdit
    participant MemoryPublic
    User->>BasicModule: Press MS key
    BasicModule->>ExpressionBar: settingLinkage()
    BasicModule->>InputEdit: getMemoryAnswer()
    InputEdit-->>BasicModule: (isCalculable, result)
    alt Expression is calculable
        BasicModule->>MemoryPublic: generateData(result)
    else Expression is not calculable
        BasicModule-->>BasicModule: Do not store to memory
    end
Loading

File-Level Changes

Change Details Files
Guard MS storage behind valid-expression check and add explanatory comment
  • Insert comment clarifying why invalid expressions shouldn’t be stored
  • Wrap memory-store call in braces under the if-check
  • Move generateData invocation inside the new block
src/widgets/basicmodule.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link

deepin pr auto review

我来对这个代码变更进行审查:

  1. 代码语法和逻辑:
  • 语法正确,添加了花括号来明确if语句的作用域,这是一个好的实践。
  • 逻辑上,添加的注释很好地解释了为什么需要这个判断条件,提高了代码的可读性。
  1. 代码质量改进建议:
  • 注释风格建议统一:建议使用中文注释时保持全角空格,如"// 仅当输入栏存在可计算结果时才执行MS存储"中"仅当"前面应该加一个全角空格。
  • 考虑将长注释拆分为多行,以提高可读性:
// 仅当输入栏存在可计算结果时才执行MS存储
// 避免将无效表达式(如未完结的"89×")错误存为0
  1. 代码性能:
  • 这次变更不会对性能产生显著影响,因为只是添加了花括号和注释。
  1. 代码安全:
  • 这次变更提高了代码的安全性,通过更明确的判断避免了无效表达式的错误存储。
  • 建议考虑在getMemoryAnswer()方法中增加空指针检查,以防止潜在的空指针访问。
  1. 其他建议:
  • 可以考虑将判断条件提取为一个独立的布尔变量,使代码更具可读性:
bool hasValidResult = m_expressionBar->getInputEdit()->getMemoryAnswer().first;
if (hasValidResult) {
    qInfo() << "Generating memory data from keypad";
    m_memoryPublic->generateData(m_expressionBar->getInputEdit()->getMemoryAnswer().second);
}

总体来说,这是一个良好的代码改进,提高了代码的可读性和安全性。建议在后续开发中继续保持这种良好的注释习惯。

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: JWWTSL, lzwind

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

@JWWTSL
Copy link
Contributor Author

JWWTSL commented Nov 14, 2025

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Nov 14, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 3090751 into linuxdeepin:master Nov 14, 2025
17 of 18 checks passed
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