From 1619b0c22d50ccc0cfbf42040a7fef3824f58929 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Fri, 7 Nov 2025 16:34:33 -0800 Subject: [PATCH 1/2] compose: Add a `controller.dispose` call that we forgot We do this at the other sites where there's an existing controller that we want to replace with a new one. I suppose this fixes a small memory leak; I just noticed it from reading code, not from profiling or anything. --- lib/widgets/compose_box.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/widgets/compose_box.dart b/lib/widgets/compose_box.dart index 1b00654b8f..8fcec9c526 100644 --- a/lib/widgets/compose_box.dart +++ b/lib/widgets/compose_box.dart @@ -1989,6 +1989,7 @@ class _ComposeBoxState extends State with PerAccountStoreAwareStateM final store = PerAccountStoreWidget.of(context); final outboxMessage = store.takeOutboxMessage(localMessageId); setState(() { + this.controller.dispose(); _setNewController(store); final controller = this.controller; controller From 3ae958e3e99577adeaca0048b0d829030e2e8368 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Fri, 7 Nov 2025 16:38:05 -0800 Subject: [PATCH 2/2] compose [nfc]: Put `_controller?.dispose` inside `_setNewController` --- lib/widgets/compose_box.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/widgets/compose_box.dart b/lib/widgets/compose_box.dart index 8fcec9c526..6e83356042 100644 --- a/lib/widgets/compose_box.dart +++ b/lib/widgets/compose_box.dart @@ -1989,7 +1989,6 @@ class _ComposeBoxState extends State with PerAccountStoreAwareStateM final store = PerAccountStoreWidget.of(context); final outboxMessage = store.takeOutboxMessage(localMessageId); setState(() { - this.controller.dispose(); _setNewController(store); final controller = this.controller; controller @@ -2092,7 +2091,6 @@ class _ComposeBoxState extends State with PerAccountStoreAwareStateM // Fetch-raw-content failed; abort the edit session. // An error dialog was already shown, by fetchRawContentWithFeedback. setState(() { - controller.dispose(); _setNewController(PerAccountStoreWidget.of(context)); }); return; @@ -2120,7 +2118,6 @@ class _ComposeBoxState extends State with PerAccountStoreAwareStateM final store = PerAccountStoreWidget.of(context); setState(() { - controller.dispose(); _setNewController(store); }); } @@ -2145,6 +2142,7 @@ class _ComposeBoxState extends State with PerAccountStoreAwareStateM } void _setNewController(PerAccountStore store) { + _controller?.dispose(); // `?.` because this might be the first call switch (widget.narrow) { case ChannelNarrow(): _controller = StreamComposeBoxController(store: store);