Unverified Commit 684980e9 authored by Binni Goel's avatar Binni Goel Committed by GitHub

SemanticOwner should dispatch creation and disposal events (#138388)

parent 0f42d194
......@@ -3281,7 +3281,17 @@ class SemanticsOwner extends ChangeNotifier {
/// Creates a [SemanticsOwner] that manages zero or more [SemanticsNode] objects.
SemanticsOwner({
required this.onSemanticsUpdate,
});
}){
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/semantics.dart',
className: '$SemanticsOwner',
object: this,
);
}
}
/// The [onSemanticsUpdate] callback is expected to dispatch [SemanticsUpdate]s
/// to the [FlutterView] that is associated with this [PipelineOwner] and/or
......@@ -3302,6 +3312,9 @@ class SemanticsOwner extends ChangeNotifier {
@override
void dispose() {
if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this);
}
_dirtyNodes.clear();
_nodes.clear();
_detachedNodes.clear();
......
......@@ -6,6 +6,7 @@ import 'dart:ui';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'package:vector_math/vector_math_64.dart';
import '../rendering/rendering_tester.dart';
......@@ -965,6 +966,16 @@ void main() {
expect(config.onTap, same(onTap));
expect(config.customSemanticsActions[customAction], same(onCustomAction));
});
test('SemanticsOwner dispatches memory events', () async {
await expectLater(
await memoryEvents(() => SemanticsOwner(
onSemanticsUpdate: (SemanticsUpdate update) {},
).dispose(), SemanticsOwner),
areCreateAndDispose,
);
});
}
class TestRender extends RenderProxyBox {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment