fix(ui): clean up store subscription on NotificationCenter.destroy()#1677
fix(ui): clean up store subscription on NotificationCenter.destroy()#1677atul-upadhyay-7 wants to merge 1 commit into
Conversation
NotificationCenter subscribes to NotificationStore in its constructor but only cleaned up in unmount(). The base Widget.destroy() does not call unmount(), so the subscription was never removed when the widget was destroyed, causing memory leaks and callbacks on destroyed widgets. Extract shared cleanup into a private _cleanup() method and call it from both unmount() and a new destroy() override. Closes Karanjot786#1662
|
Hi @atul-upadhyay-7 👋 ⭐ Star this repo before your PR merges. Why? GSSoC 2026 contributors who star get priority review and points credit. After you star, push any commit (or re-run this check). The Thanks for your contribution to TermUI. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
NotificationCenter destroy() lifecycle fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 Warning |
Summary
Fixes a memory leak in
NotificationCenterwhere the store subscription was never cleaned up when the widget was destroyed viadestroy().Closes #1662
Root Cause
NotificationCentersubscribes toNotificationStorein its constructor and only unsubscribes inunmount(). The baseWidget.destroy()method does not callunmount()— it only clears children, emits the unmount event, removes event listeners, and nulls the parent. This left the store subscription alive, causing:markDirty()on dead instances)Fix
Extracted the subscription cleanup logic into a private
_cleanup()method and call it from bothunmount()and a newdestroy()override:Tests added
Verification
Summary by CodeRabbit
Release Notes
destroy()can be safely called multiple times without errors.