-
Notifications
You must be signed in to change notification settings - Fork 102
fix: code optimization #952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR fully removes Firefox DPI scaling support (including its tests) to eliminate related audio crashes, and strengthens updateDefaultSink by moving the sinkInfo nil check earlier to avoid null pointer dereferences. Class diagram for removed Firefox DPI scaling code in XSManagerclassDiagram
class XSManager {
+updateXResources()
-updateFirefoxDPI() // Removed
}
%% The following helper functions were also removed:
class getFirefoxConfigs {
-getFirefoxConfigs(dir string) ([]string, error) // Removed
}
class setFirefoxDPI {
-setFirefoxDPI(value float64, src, dest string) error // Removed
}
XSManager --|> getFirefoxConfigs : used
XSManager --|> setFirefoxDPI : used
Class diagram for updated Audio.updateDefaultSink() methodclassDiagram
class Audio {
+updateDefaultSink(sinkName string)
-defaultSinkName : string
-defaultSink
+setPropDefaultSink(path string)
+moveSinkInputsToSink(sink)
}
%% updateDefaultSink now checks sinkInfo == nil earlier to prevent null pointer dereference.
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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 - here's some feedback:
- Remove any leftover imports or constants in xsettings_dpi.go that are no longer used after deleting the Firefox DPI code to avoid dead code.
- Add a unit test or integration scenario for the new early-return path in updateDefaultSink to verify nil sinkInfo handling works as expected.
- Consider renaming or updating comments around updateDPI/updateXResources to reflect that Firefox DPI scaling has been removed, improving code clarity.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Remove any leftover imports or constants in xsettings_dpi.go that are no longer used after deleting the Firefox DPI code to avoid dead code.
- Add a unit test or integration scenario for the new early-return path in updateDefaultSink to verify nil sinkInfo handling works as expected.
- Consider renaming or updating comments around updateDPI/updateXResources to reflect that Firefox DPI scaling has been removed, improving code clarity.
## Individual Comments
### Comment 1
<location> `audio1/audio.go:1396-1401` </location>
<code_context>
logger.Info("virtual sink is", sinkName, ",sink_master is", sinkInfo.Name)
}
-
+ if sinkInfo == nil {
+ logger.Warning("failed to get sinkInfo for name:", sinkName)
+ a.setPropDefaultSink("/")
+ a.defaultSinkName = ""
+ a.defaultSink = nil
+ return
+ }
a.moveSinkInputsToSink(nil)
</code_context>
<issue_to_address>
**suggestion:** Duplicate nil check for sinkInfo can be removed.
Since the nil check is now handled earlier, please remove the redundant check and any unreachable code below to improve readability.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602, mhduiy 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 |
1. Fix an audio crash issue 2. Remove Firefox DPI settings Influence: audio/firefox
deepin pr auto review我来对这段代码进行审查分析:
if sinkInfo == nil {
logger.Warning("failed to get sinkInfo for name:", sinkName)
a.setPropDefaultSink("/")
a.defaultSinkName = ""
a.defaultSink = nil
return
}优点:
建议:
- go m.updateFirefoxDPI()优点:
优点:
优点:
总体评价:
建议:
这些修改整体上是积极的,提高了代码的质量和可维护性。 |
Influence: audio/firefox