Unverified Commit 8e94423e authored by auto-submit[bot]'s avatar auto-submit[bot] Committed by GitHub

Reverts "BoxPainter should dispatch creation and disposal events." (#141545)

Reverts flutter/flutter#141526
Initiated by: CaseyHillers
This change reverts the following previous change:
Original Description:
### Description
- Adds `BoxPainter` creation and disposal events dispatching for memory leak tracking as part of https://github.com/flutter/flutter/issues/141198

### Tests
- Updates `decoration_test.dart` to test `BoxPainter` object creation and disposal events dispatching.
parent e5f62cc5
...@@ -198,18 +198,9 @@ abstract class Decoration with Diagnosticable { ...@@ -198,18 +198,9 @@ abstract class Decoration with Diagnosticable {
/// happens, the [onChanged] callback will be invoked. To stop this callback /// happens, the [onChanged] callback will be invoked. To stop this callback
/// from being called after the painter has been discarded, call [dispose]. /// from being called after the painter has been discarded, call [dispose].
abstract class BoxPainter { abstract class BoxPainter {
/// Default abstract constructor for box painters. /// Abstract const constructor. This constructor enables subclasses to provide
BoxPainter([this.onChanged]) { /// const constructors so that they can be used in const expressions.
// TODO(polina-c): stop duplicating code across disposables const BoxPainter([this.onChanged]);
// https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/painting.dart',
className: '$BoxPainter',
object: this,
);
}
}
/// Paints the [Decoration] for which this object was created on the /// Paints the [Decoration] for which this object was created on the
/// given canvas using the given configuration. /// given canvas using the given configuration.
...@@ -252,9 +243,5 @@ abstract class BoxPainter { ...@@ -252,9 +243,5 @@ abstract class BoxPainter {
/// The [onChanged] callback will not be invoked after this method has been /// The [onChanged] callback will not be invoked after this method has been
/// called. /// called.
@mustCallSuper @mustCallSuper
void dispose() { void dispose() { }
if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
}
}
} }
...@@ -9,7 +9,6 @@ import 'package:fake_async/fake_async.dart'; ...@@ -9,7 +9,6 @@ import 'package:fake_async/fake_async.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../image_data.dart'; import '../image_data.dart';
import '../painting/mocks_for_image_cache.dart'; import '../painting/mocks_for_image_cache.dart';
...@@ -814,16 +813,4 @@ void main() { ...@@ -814,16 +813,4 @@ void main() {
info.dispose(); info.dispose();
}, skip: kIsWeb); // https://github.com/flutter/flutter/issues/87442 }, skip: kIsWeb); // https://github.com/flutter/flutter/issues/87442
test('$BoxPainter dispatches memory events', () async {
await expectLater(
await memoryEvents(() => _BoxPainter().dispose(), _BoxPainter),
areCreateAndDispose,
);
});
}
class _BoxPainter extends BoxPainter {
@override
void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {}
} }
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