From 44ee3bf85a51be5aa664dadecd290b9be0ab012c Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 13 Jul 2017 17:22:37 +0200 Subject: [PATCH] wineandroid: Hold on to the native window until we get a new one. Signed-off-by: Alexandre Julliard --- dlls/wineandroid.drv/WineActivity.java | 16 +++++++++++++--- dlls/wineandroid.drv/device.c | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dlls/wineandroid.drv/WineActivity.java b/dlls/wineandroid.drv/WineActivity.java index d1fe305a68a..5a99e0734bc 100644 --- a/dlls/wineandroid.drv/WineActivity.java +++ b/dlls/wineandroid.drv/WineActivity.java @@ -311,6 +311,8 @@ protected class WineWindow extends Object protected WineWindow parent; protected Surface window_surface; protected Surface client_surface; + protected SurfaceTexture window_surftex; + protected SurfaceTexture client_surftex; protected WineWindowGroup window_group; protected WineWindowGroup client_group; @@ -442,14 +444,22 @@ public void set_surface( SurfaceTexture surftex, boolean is_client ) if (is_client) { if (surftex == null) client_surface = null; - else if (client_surface == null) client_surface = new Surface( surftex ); + else if (surftex != client_surftex) + { + client_surftex = surftex; + client_surface = new Surface( surftex ); + } Log.i( LOGTAG, String.format( "set client surface hwnd %08x %s", hwnd, client_surface )); wine_surface_changed( hwnd, client_surface, true ); } else { if (surftex == null) window_surface = null; - else if (window_surface == null) window_surface = new Surface( surftex ); + else if (surftex != window_surftex) + { + window_surftex = surftex; + window_surface = new Surface( surftex ); + } Log.i( LOGTAG, String.format( "set window surface hwnd %08x %s", hwnd, window_surface )); wine_surface_changed( hwnd, window_surface, false ); } @@ -567,7 +577,7 @@ public boolean onSurfaceTextureDestroyed( SurfaceTexture surftex ) Log.i( LOGTAG, String.format( "onSurfaceTextureDestroyed win %08x %s", window.hwnd, is_client ? "client" : "whole" )); window.set_surface( null, is_client ); - return true; + return false; // hold on to the texture since the app may still be using it } public void onSurfaceTextureUpdated(SurfaceTexture surftex) diff --git a/dlls/wineandroid.drv/device.c b/dlls/wineandroid.drv/device.c index 3911d2110a3..0ccae1130c7 100644 --- a/dlls/wineandroid.drv/device.c +++ b/dlls/wineandroid.drv/device.c @@ -463,6 +463,8 @@ static void CALLBACK register_native_window_callback( ULONG_PTR arg1, ULONG_PTR BOOL opengl = arg3; struct native_win_data *data = get_native_win_data( hwnd, opengl ); + if (!win) return; /* do nothing and hold on to the window until we get a new surface */ + if (!data || data->parent == win) { if (win) pANativeWindow_release( win );