properly null out texture references on disposal
This commit is contained in:
@@ -56,10 +56,12 @@ class _ThermionTextureWidgetState extends State<ThermionTextureWidget> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
final texture = _texture;
|
||||||
|
_texture = null;
|
||||||
super.dispose();
|
super.dispose();
|
||||||
_views.remove(widget.viewer.view);
|
_views.remove(widget.viewer.view);
|
||||||
if (_texture != null) {
|
if (texture != null) {
|
||||||
ThermionFlutterPlatform.instance.destroyTextureDescriptor(_texture!);
|
ThermionFlutterPlatform.instance.destroyTextureDescriptor(texture!);
|
||||||
}
|
}
|
||||||
_fpsUpdateTimer?.cancel();
|
_fpsUpdateTimer?.cancel();
|
||||||
_states.remove(this);
|
_states.remove(this);
|
||||||
@@ -131,6 +133,7 @@ class _ThermionTextureWidgetState extends State<ThermionTextureWidget> {
|
|||||||
|
|
||||||
widget.viewer.onDispose(() async {
|
widget.viewer.onDispose(() async {
|
||||||
var texture = _texture;
|
var texture = _texture;
|
||||||
|
_texture = null;
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user