Merged
Conversation
Copilot started reviewing on behalf of
NullPointerDepressiveDisorder
February 17, 2026 10:10
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the DeviceMonitor class where a stale global reference (gDeviceMonitor) could prevent new monitor instances from functioning correctly after a failed start() call. The fix ensures proper cleanup of global state even when monitoring never successfully started, which is critical for the C callback infrastructure used by the MultitouchSupport framework.
Changes:
- Modified
DeviceMonitor.stop()to clean upgDeviceMonitorglobal reference even whenisRunningis false - Added test case to verify global reference cleanup after failed
start()attempts
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| MiddleDrag/Managers/DeviceMonitor.swift | Added early-return path in stop() to clean up global reference (gDeviceMonitor) when monitor owns the reference but was never started, preventing stale references from blocking future monitor instances |
| MiddleDrag/MiddleDragTests/DeviceMonitorTests.swift | Added testStopCleansUpGlobalReferenceWhenStartFailed to verify that stop() properly clears global reference after failed start(), allowing new monitors to take ownership |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request addresses a bug in the
DeviceMonitorclass where a stale global reference (gDeviceMonitor) could prevent new instances from registering correctly ifstart()failed (for example, when no device is found). The fix ensures thatstop()cleans up the global reference even when the monitor is not running, preventing callbacks from being dispatched to a dead instance. A new test is added to verify this behavior.Bug fix for global reference cleanup:
DeviceMonitor.stop()to clean up the global reference (gDeviceMonitor) even ifisRunningis false, ensuring that failedstart()attempts do not leave a stale reference and block future monitors from registering.Testing improvements:
testStopCleansUpGlobalReferenceWhenStartFailedto verify that after a failedstart(), callingstop()properly clears the global reference, allowing a newDeviceMonitorto take ownership.