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