memory leak fixes
This commit is contained in:
parent
929d7c25fd
commit
72a6af5040
3 changed files with 23 additions and 1 deletions
|
@ -9,6 +9,7 @@ class MultiPageInfo {
|
|||
final AvesEntry mainEntry;
|
||||
final List<SinglePageInfo> _pages;
|
||||
final Map<SinglePageInfo, AvesEntry> _pageEntries = {};
|
||||
final Set<AvesEntry> _transientEntries = <AvesEntry>{};
|
||||
|
||||
int get pageCount => _pages.length;
|
||||
|
||||
|
@ -16,6 +17,13 @@ class MultiPageInfo {
|
|||
required this.mainEntry,
|
||||
required List<SinglePageInfo> pages,
|
||||
}) : _pages = pages {
|
||||
if (kFlutterMemoryAllocationsEnabled) {
|
||||
MemoryAllocations.instance.dispatchObjectCreated(
|
||||
library: 'aves',
|
||||
className: '$MultiPageInfo',
|
||||
object: this,
|
||||
);
|
||||
}
|
||||
if (_pages.isNotEmpty) {
|
||||
_pages.sort();
|
||||
// make sure there is a page marked as default
|
||||
|
@ -34,6 +42,13 @@ class MultiPageInfo {
|
|||
}
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
if (kFlutterMemoryAllocationsEnabled) {
|
||||
MemoryAllocations.instance.dispatchObjectDisposed(object: this);
|
||||
}
|
||||
_transientEntries.forEach((entry) => entry.dispose());
|
||||
}
|
||||
|
||||
factory MultiPageInfo.fromPageMaps(AvesEntry mainEntry, List<Map> pageMaps) {
|
||||
return MultiPageInfo(
|
||||
mainEntry: mainEntry,
|
||||
|
@ -91,7 +106,7 @@ class MultiPageInfo {
|
|||
// dynamically extracted video is not in the trash like the original motion photo
|
||||
final trashed = (mainEntry.isMotionPhoto && pageInfo.isVideo) ? false : mainEntry.trashed;
|
||||
|
||||
return AvesEntry(
|
||||
final pageEntry = AvesEntry(
|
||||
id: mainEntry.id,
|
||||
uri: pageInfo.uri ?? mainEntry.uri,
|
||||
path: mainEntry.path,
|
||||
|
@ -117,6 +132,8 @@ class MultiPageInfo {
|
|||
)
|
||||
..addressDetails = mainEntry.addressDetails?.copyWith()
|
||||
..trashDetails = trashed ? mainEntry.trashDetails : null;
|
||||
_transientEntries.add(pageEntry);
|
||||
return pageEntry;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -9,6 +9,7 @@ import 'package:aves/model/filters/album.dart';
|
|||
import 'package:aves/model/filters/trash.dart';
|
||||
import 'package:aves/model/highlight.dart';
|
||||
import 'package:aves/model/metadata/date_modifier.dart';
|
||||
import 'package:aves/model/multipage.dart';
|
||||
import 'package:aves/model/settings/settings.dart';
|
||||
import 'package:aves/model/source/collection_lens.dart';
|
||||
import 'package:aves/model/source/collection_source.dart';
|
||||
|
@ -49,11 +50,13 @@ mixin EntryStorageMixin on FeedbackMixin, PermissionAwareMixin, SizeAwareMixin {
|
|||
|
||||
if (!await checkFreeSpaceForMove(context, targetEntries, destinationAlbum, MoveType.export)) return;
|
||||
|
||||
final transientMultiPageInfo = <MultiPageInfo>{};
|
||||
final selection = <AvesEntry>{};
|
||||
await Future.forEach(targetEntries, (targetEntry) async {
|
||||
if (targetEntry.isMultiPage) {
|
||||
final multiPageInfo = await targetEntry.getMultiPageInfo();
|
||||
if (multiPageInfo != null) {
|
||||
transientMultiPageInfo.add(multiPageInfo);
|
||||
if (targetEntry.isMotionPhoto) {
|
||||
await multiPageInfo.extractMotionPhotoVideo();
|
||||
}
|
||||
|
@ -130,6 +133,7 @@ mixin EntryStorageMixin on FeedbackMixin, PermissionAwareMixin, SizeAwareMixin {
|
|||
}
|
||||
},
|
||||
);
|
||||
transientMultiPageInfo.forEach((v) => v.dispose());
|
||||
}
|
||||
|
||||
Future<void> doQuickMove(
|
||||
|
|
|
@ -50,6 +50,7 @@ class MultiPageController {
|
|||
if (kFlutterMemoryAllocationsEnabled) {
|
||||
MemoryAllocations.instance.dispatchObjectDisposed(object: this);
|
||||
}
|
||||
_info?.dispose();
|
||||
_disposed = true;
|
||||
pageNotifier.dispose();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue