dde-calendar icon indicating copy to clipboard operation
dde-calendar copied to clipboard

fix: 修复重复删除相同日程数据崩溃问题

Open myk1343 opened this issue 7 months ago • 2 comments

修复重复删除相同日程数据崩溃问题 Bug: https://pms.uniontech.com/bug-view-303095.html Log: 修复重复删除相同日程数据崩溃问题

Summary by Sourcery

Bug Fixes:

  • Prevent application crash when attempting to delete the same schedule item multiple times by adding visibility checks and modifying the delete method to return a boolean status

myk1343 avatar Apr 11 '25 09:04 myk1343

Reviewer's Guide by Sourcery

This pull request fixes a crash that occurs when attempting to delete the same schedule data multiple times. The fix ensures that a schedule item is only deleted once by checking its visibility before allowing deletion and hiding the item after a successful deletion.

Sequence diagram for deleting a schedule item

sequenceDiagram
    participant User
    participant DragInfoGraphicsView
    participant DragInfoItem
    participant CScheduleOperation

    User->>DragInfoGraphicsView: Right-clicks on schedule item
    DragInfoGraphicsView->>DragInfoItem: infoitem = dynamic_cast(item)
    alt infoitem != nullptr && infoitem->isVisible()
        DragInfoGraphicsView->>DragInfoGraphicsView: DeleteItem(infoitem->getData())
        DragInfoGraphicsView->>CScheduleOperation: _scheduleOperation.deleteSchedule(info)
        CScheduleOperation-->>DragInfoGraphicsView: return success
        DragInfoGraphicsView->>DragInfoItem: infoitem->setVisible(false)
    else infoitem == nullptr || !infoitem->isVisible()
        DragInfoGraphicsView-->>User: No action
    end

Updated class diagram for DragInfoGraphicsView

classDiagram
    class DragInfoGraphicsView {
        -QMenu* m_rightMenu
        -QAction* m_deleteAction
        +DeleteItem(DSchedule::Ptr info) bool
        +contextMenuEvent(QContextMenuEvent *event)
        +slotContextMenu(CFocusItem *item)
    }

    DragInfoGraphicsView -- CScheduleOperation : Uses
    DragInfoGraphicsView -- DragInfoItem : Uses

    class CScheduleOperation {
        +deleteSchedule(DSchedule::Ptr info) bool
        +isFestival(DSchedule::Ptr info) bool
    }

    class DragInfoItem {
        +setVisible(bool visible)
        +getData() DSchedule::Ptr
        +isVisible() bool
    }

    note for DragInfoGraphicsView "DeleteItem now returns a boolean indicating success."
    note for DragInfoItem "Added isVisible() method."

File-Level Changes

Change Details Files
Added a visibility check before deleting a schedule item and hiding the item after deletion to prevent multiple deletions of the same data.
  • Added a check to ensure infoitem is visible before proceeding with context menu actions.
  • Added a check to ensure infoitem is visible before proceeding with slot context menu actions.
  • Modified DeleteItem to return a boolean indicating successful deletion.
  • Set the visibility of infoitem to false after a successful deletion in contextMenuEvent.
  • Set the visibility of infoitem to false after a successful deletion in slotContextMenu.
calendar-client/src/view/draginfographicsview.cpp
calendar-client/src/view/draginfographicsview.h

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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on an issue to generate a plan of action for it.

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

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Apr 11 '25 09:04 sourcery-ai[bot]

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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

deepin-ci-robot avatar Apr 14 '25 01:04 deepin-ci-robot

/forcemerge

myk1343 avatar Apr 14 '25 01:04 myk1343

This pr force merged! (status: unstable)

deepin-bot[bot] avatar Apr 14 '25 01:04 deepin-bot[bot]