cursor: say what Future.sync defers, and give the default cursor time on a slow runner

The comment on the fetch in restorePixels read as if the fetch were put
off; it runs at once, and Future.sync only turns its throw into an error
the await hands over later, which is what keeps the notify out of the
build.

cursor_default_test gave the default cursor 100 ms to decode, which a
slow runner may miss. It cannot wait for the cursor itself, since asking
for it would make it; it now waits 500 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab
This commit is contained in:
rustdesk
2026-09-25 11:55:39 +08:00
co-authored by Claude Opus 5.5
parent 547acba702
commit f48b6c0d72
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -3742,7 +3742,8 @@ class CursorModel with ChangeNotifier {
final generation = _generation;
() async {
try {
// Never at once: a build may be what asked, and a failure tells the listeners.
// A throw becomes an error the await hands over later, not during the build that may
// have asked: a failure tells the listeners.
final shape = await Future.sync(() => fetchCursorShape(id));
if (generation != _generation) {
return;
+2 -1
View File
@@ -54,7 +54,8 @@ void main() {
final evt = {'id': '2'};
ffi.ffiModel.updateLastCursorId(evt);
ffi.ffiModel.handleCursorId(evt);
await Future<void>.delayed(const Duration(milliseconds: 100));
// Not a wait for the default cursor itself: asking for it would make it.
await Future<void>.delayed(const Duration(milliseconds: 500));
expect(cursor.cache, isNull);
final built = _key(buildCursorOfCache(
cursor, 1.0, cursor.cache ?? preDefaultCursor.cache));