From 1dc96e4fd2d86656ccb965fdf78e5bbc6f6a7b98 Mon Sep 17 00:00:00 2001 From: dignow Date: Wed, 16 Aug 2023 21:48:49 +0800 Subject: [PATCH] Do not unregister texture if move to new window Signed-off-by: dignow --- flutter/lib/desktop/pages/remote_page.dart | 2 +- flutter/lib/models/desktop_render_texture.dart | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/flutter/lib/desktop/pages/remote_page.dart b/flutter/lib/desktop/pages/remote_page.dart index 28212e4ca..a417286ff 100644 --- a/flutter/lib/desktop/pages/remote_page.dart +++ b/flutter/lib/desktop/pages/remote_page.dart @@ -204,7 +204,7 @@ class _RemotePageState extends State // https://github.com/flutter/flutter/issues/64935 super.dispose(); debugPrint("REMOTE PAGE dispose session $sessionId ${widget.id}"); - await _renderTexture.destroy(); + await _renderTexture.destroy(closeSession); // ensure we leave this session, this is a double check bind.sessionEnterOrLeave(sessionId: sessionId, enter: false); DesktopMultiWindow.removeListener(this); diff --git a/flutter/lib/models/desktop_render_texture.dart b/flutter/lib/models/desktop_render_texture.dart index f59373623..49864642c 100644 --- a/flutter/lib/models/desktop_render_texture.dart +++ b/flutter/lib/models/desktop_render_texture.dart @@ -31,9 +31,11 @@ class RenderTexture { } } - destroy() async { + destroy(bool unregisterTexture) async { if (useTextureRender && _textureKey != -1 && _sessionId != null) { - platformFFI.registerTexture(_sessionId!, 0); + if (unregisterTexture) { + platformFFI.registerTexture(_sessionId!, 0); + } await textureRenderer.closeTexture(_textureKey); _textureKey = -1; }