fix: timeDate plugin crash#321
Conversation
Reviewer's GuideThis PR introduces a MAX_DISTANCE guard to prevent invalid font-size calculations when the dock size isn’t updated, updates the font-size map bound, adds logging for dock size changes, and refines when font-size adjustment runs after a dock position change. Updated Class Diagram for DatetimeWidgetclassDiagram
class DatetimeWidget {
+adjustFontSize() void
+setDockPanelSize(const QSize &dockSize) void
+dockPositionChanged() void
}
Flow Diagram for adjustFontSize Logicgraph TD
A[Start adjustFontSize] --> B(Get dock position from qApp);
B --> C(Calculate validDistance);
C --> D{validDistance > MAX_DISTANCE?};
D -- Yes --> E[Return early];
D -- No --> F(Calculate font size using fontSizeMap);
F --> G[Apply font size];
G --> H[End adjustFontSize];
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @yixinshark - I've reviewed your changes - here's some feedback:
- Instead of returning early when validDistance exceeds MAX_DISTANCE, consider clamping it to MAX_DISTANCE so that maximum font sizes still get applied instead of skipping adjustment altogether.
- The new qInfo() call in setDockPanelSize may clutter production logs—consider switching it to qDebug() or guarding it behind a verbosity check.
- The hard-coded MAX_DISTANCE value (999) is arbitrary; think about deriving it from the fontSizeMap or documenting its origin to simplify future maintenance.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| validDistance = m_dockSize.width() / devicePixelRatioF(); | ||
| } | ||
|
|
||
| // dock position changed(from bottom to left), new dock size is not update, use bottom width to adjust font size, |
There was a problem hiding this comment.
nitpick: Improve clarity of English comment
The comment is unclear and has grammatical errors. Please rewrite it to clearly explain the fallback logic, such as: "If dock position changes before m_dockSize updates, use previous dimensions to prevent font size assertions."
5a238c9 to
3bb5bd5
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, yixinshark The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
3bb5bd5 to
3433192
Compare
dock position changed(from bottom to left), new dock size is not update, use bottom width to adjust font size, then assert in timeFontSize != 0 && dateFontSize != 0 Log: as title
3433192 to
49fe536
Compare
|
@yixinshark: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
deepin pr auto review代码审查意见:
综合以上意见,代码可以进一步优化以提高可读性、性能和健壮性。 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
dock position changed(from bottom to left), new dock size is not update, use bottom width to adjust font size, then assert in timeFontSize != 0 && dateFontSize != 0
Log: as title
Summary by Sourcery
Prevent invalid dock size values from causing font size assertion failures and ensure font size adjustment occurs after dock position changes.
Bug Fixes:
Enhancements: