cursor: count a shape held again when its asked raster has a native cursor

A lookup that missed took the shape out of _nativeIds, but one that hit
did not put it back. A shape asked at a new raster, then at one it has a
native cursor for, still counted as waiting: a restore finishing after
the switch away kept its pixels in _awaitingNative instead of letting
them go. The set now says whether the raster asked last has a native
cursor, either way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab
This commit is contained in:
rustdeskandClaude Opus 5.5 committed 2026-09-24 15:27:05 +08:00
1 parent 1e4388771f
commit 7cefbfc7a7
2 files changed
+28 -2

No files matched your search

+7 -2
View File
@@ -3619,8 +3619,13 @@ class CursorModel with ChangeNotifier {
String nativeKey(CursorData cache, double scale) {
final key = '${_keyScope}_${cache.updateGetKey(scale)}';
// A native cursor at another raster does not hold the pixels this one is made from.
if (!_cacheKeys.contains(key)) _nativeIds.remove(cache.id);
// A shape is held by a native cursor at the raster asked last; one at another raster does
// not hold the pixels this one is made from.
if (_cacheKeys.contains(key)) {
_nativeIds.add(cache.id);
} else {
_nativeIds.remove(cache.id);
}
return key;
}
+21
View File
@@ -267,6 +267,27 @@ void main() {
isNotEmpty);
});
test('a raster returned to counts again as held by its native cursor',
() async {
final cursor = ffi.cursorModel;
await _feed(ffi, 'A', size: 32);
buildCursorOfCache(cursor, 1.0, cursor.cache);
await _settle();
await _feed(ffi, 'B');
buildCursorOfCache(cursor, 1.0, cursor.cache);
await _settle();
_select(ffi, 'A');
ffi.cursor.holdFetches = true;
buildCursorOfCache(cursor, 0.5, cursor.cache); // no cursor at 0.5: fetched
buildCursorOfCache(cursor, 1.0, cursor.cache); // back at 1.0, which has one
_select(ffi, 'B');
ffi.cursor.answerFetches();
await _settle();
expect(cursor.cachedShape('A')!.hasPixels, isFalse,
reason: 'its native cursor at the raster asked last holds it');
});
test('shapes waiting for a native cursor keep their pixels, within the limit',
() async {
const max = CursorModel.kRecentShapes;