ADFA-3030 | Prevent tab access crash when content is null#1023
ADFA-3030 | Prevent tab access crash when content is null#1023
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughRelease Notes - ADFA-3030: Prevent Tab Access Crash When Content Is Null
WalkthroughAdds null-safety guards to tab- and content-related operations in EditorHandlerActivity: methods now use a local Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Prevent crashes when activity is destroyed during async UI updates
2eb01b0 to
5dd5c9b
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt`:
- Around line 554-556: The code returns 0 when contentOrNull is null (in
EditorHandlerActivity functions such as where safeContent is assigned and in
openFileAndGetIndex), which treats teardown as a valid tab index; change the
early-return value to a sentinel invalid index (e.g., -1) instead of 0, and
update all similar guards (the block around safeContent and the similar guard at
lines 558-564) so callers can detect and ignore the teardown case; ensure any
call sites that expect an index now treat negative values as "not
found"/teardown and avoid dereferencing content when the sentinel is returned.
Description
This PR adds minimal null-safety guards around tab/content access paths that can run after the activity is destroyed (e.g., with “Don’t keep activities” enabled).
It prevents
NullPointerException/state issues by early-returning whencontentOrNullis unavailable, while keeping existing behavior unchanged in normal flows.Details
Before fix
Before.fix.mov
After fix
After.fix.mov
Ticket
ADFA-3030