mirror of
https://github.com/immich-app/immich.git
synced 2025-07-31 15:08:44 -04:00
fix disposal
This commit is contained in:
parent
366437043d
commit
d670ed18af
@ -88,7 +88,6 @@ class Thumbnail extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ThumbnailState extends State<Thumbnail> {
|
class _ThumbnailState extends State<Thumbnail> {
|
||||||
ui.Image? _thumbhashImage;
|
|
||||||
ui.Image? _providerImage;
|
ui.Image? _providerImage;
|
||||||
ImageStream? _imageStream;
|
ImageStream? _imageStream;
|
||||||
ImageStreamListener? _imageStreamListener;
|
ImageStreamListener? _imageStreamListener;
|
||||||
@ -104,10 +103,17 @@ class _ThumbnailState extends State<Thumbnail> {
|
|||||||
@override
|
@override
|
||||||
void didUpdateWidget(Thumbnail oldWidget) {
|
void didUpdateWidget(Thumbnail oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
if (oldWidget.imageProvider != widget.imageProvider ||
|
if (widget.imageProvider != oldWidget.imageProvider) {
|
||||||
(_providerImage == null &&
|
return _loadImage();
|
||||||
(widget.thumbhashMode != ThumbhashMode.disabled && oldWidget.blurhash != widget.blurhash) ||
|
}
|
||||||
(oldWidget.thumbhashMode == ThumbhashMode.disabled && widget.thumbhashMode != ThumbhashMode.disabled))) {
|
|
||||||
|
if (_providerImage != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((oldWidget.thumbhashMode == ThumbhashMode.disabled && widget.thumbhashMode != ThumbhashMode.disabled) ||
|
||||||
|
(oldWidget.thumbhashMode == ThumbhashMode.only && widget.thumbhashMode != ThumbhashMode.only) ||
|
||||||
|
(widget.thumbhashMode != ThumbhashMode.disabled && oldWidget.blurhash != widget.blurhash)) {
|
||||||
_loadImage();
|
_loadImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,7 +129,7 @@ class _ThumbnailState extends State<Thumbnail> {
|
|||||||
if (widget.thumbhashMode != ThumbhashMode.only && widget.imageProvider != null) {
|
if (widget.thumbhashMode != ThumbhashMode.only && widget.imageProvider != null) {
|
||||||
_loadFromProvider();
|
_loadFromProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widget.thumbhashMode != ThumbhashMode.disabled && widget.blurhash != null) {
|
if (widget.thumbhashMode != ThumbhashMode.disabled && widget.blurhash != null) {
|
||||||
_decodeThumbhash();
|
_decodeThumbhash();
|
||||||
}
|
}
|
||||||
@ -138,7 +144,6 @@ class _ThumbnailState extends State<Thumbnail> {
|
|||||||
(ImageInfo imageInfo, bool synchronousCall) {
|
(ImageInfo imageInfo, bool synchronousCall) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
|
|
||||||
_thumbhashImage?.dispose();
|
|
||||||
if (_providerImage != imageInfo.image) {
|
if (_providerImage != imageInfo.image) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_providerImage = imageInfo.image;
|
_providerImage = imageInfo.image;
|
||||||
@ -221,7 +226,7 @@ class _ThumbnailState extends State<Thumbnail> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return _ThumbnailLeaf(
|
return _ThumbnailLeaf(
|
||||||
image: _providerImage ?? _thumbhashImage,
|
image: _providerImage,
|
||||||
fit: widget.fit,
|
fit: widget.fit,
|
||||||
placeholderGradient: gradient,
|
placeholderGradient: gradient,
|
||||||
);
|
);
|
||||||
@ -230,7 +235,7 @@ class _ThumbnailState extends State<Thumbnail> {
|
|||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_stopListeningToStream();
|
_stopListeningToStream();
|
||||||
_thumbhashImage?.dispose();
|
_providerImage?.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,7 +308,7 @@ class _ThumbnailRenderBox extends RenderBox {
|
|||||||
markNeedsPaint();
|
markNeedsPaint();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// _previousImage?.dispose();
|
_previousImage?.dispose();
|
||||||
_previousImage = null;
|
_previousImage = null;
|
||||||
_fadeStartTime = null;
|
_fadeStartTime = null;
|
||||||
}
|
}
|
||||||
@ -348,7 +353,7 @@ class _ThumbnailRenderBox extends RenderBox {
|
|||||||
|
|
||||||
final time = DateTime.now();
|
final time = DateTime.now();
|
||||||
if (time.difference(_lastImageRequest).inMilliseconds >= 16) {
|
if (time.difference(_lastImageRequest).inMilliseconds >= 16) {
|
||||||
_fadeStartTime = DateTime.now();
|
_fadeStartTime = time;
|
||||||
_previousImage = _image;
|
_previousImage = _image;
|
||||||
}
|
}
|
||||||
_image = value;
|
_image = value;
|
||||||
@ -377,4 +382,10 @@ class _ThumbnailRenderBox extends RenderBox {
|
|||||||
markNeedsPaint();
|
markNeedsPaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
dispose() {
|
||||||
|
_previousImage?.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user