Skip to content

Commit b0620f8

Browse files
committed
fix: prevent timer memory leak in spell check
Cancel all pending debounce timers in dispose() to prevent memory leaks and potential crashes when the widget is disposed during active spell checking.
1 parent 9277fd0 commit b0620f8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/src/editor/block_component/rich_text/appflowy_rich_text.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ class _AppFlowyRichTextState extends State<AppFlowyRichText>
145145
confirmContextEnabled();
146146
}
147147

148+
@override
149+
void dispose() {
150+
// Cancel all pending spell check timers to prevent memory leaks
151+
for (final timer in _debounceTimers.values) {
152+
timer?.cancel();
153+
}
154+
_debounceTimers.clear();
155+
super.dispose();
156+
}
157+
148158
@override
149159
Widget build(BuildContext context) {
150160
Widget child = Stack(

0 commit comments

Comments
 (0)