fix, cursor hotxy, use _id

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2023-10-03 21:18:53 +08:00
parent 8b807d7b50
commit 197a9330df

View File

@ -1457,7 +1457,7 @@ class CursorModel with ChangeNotifier {
// Update last cursor data. // Update last cursor data.
// Do not use the previous `image` and `id`, because `_id` may be changed. // Do not use the previous `image` and `id`, because `_id` may be changed.
_updateCursorIdData(_id); _updateCurData();
} }
Future<bool> _updateCache( Future<bool> _updateCache(
@ -1497,9 +1497,9 @@ class CursorModel with ChangeNotifier {
return true; return true;
} }
bool _updateCursorIdData(int id) { bool _updateCurData() {
_cache = _cacheMap[id]; _cache = _cacheMap[_id];
final tmp = _images[id]; final tmp = _images[_id];
if (tmp != null) { if (tmp != null) {
_image = tmp.item1; _image = tmp.item1;
_hotx = tmp.item2; _hotx = tmp.item2;
@ -1509,7 +1509,7 @@ class CursorModel with ChangeNotifier {
notifyListeners(); notifyListeners();
} catch (e) { } catch (e) {
debugPrint( debugPrint(
'WARNING: updateCursorId $id, without notifyListeners(). $e'); 'WARNING: updateCursorId $_id, without notifyListeners(). $e');
} }
return true; return true;
} else { } else {
@ -1518,10 +1518,10 @@ class CursorModel with ChangeNotifier {
} }
updateCursorId(Map<String, dynamic> evt) async { updateCursorId(Map<String, dynamic> evt) async {
final id = int.parse(evt['id']); _id = int.parse(evt['id']);
if (!_updateCursorIdData(id)) { if (!_updateCurData()) {
debugPrint( debugPrint(
'WARNING: updateCursorId $id, cache is ${_cache == null ? "null" : "not null"}. without notifyListeners()'); 'WARNING: updateCursorId $_id, cache is ${_cache == null ? "null" : "not null"}. without notifyListeners()');
} }
} }