From 6b48a8c7c58cae5f21f4ef126e531a6b5f5b5d1f Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Thu, 18 Apr 2013 03:43:52 -0700 Subject: [PATCH] Android: Fixed possible crash with a session being null --- .../com/freerdp/freerdpcore/application/GlobalApp.java | 6 +----- .../freerdp/freerdpcore/presentation/SessionActivity.java | 8 +++++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/application/GlobalApp.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/application/GlobalApp.java index c37f8df5a..aca737a4b 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/application/GlobalApp.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/application/GlobalApp.java @@ -194,8 +194,7 @@ public class GlobalApp extends Application implements LibFreeRDP.EventListener { Log.v("LibFreeRDP", "OnConnectionFailure"); - // free session - GlobalApp.freeSession(instance); + // send notification to session activity sendRDPNotification(FREERDP_EVENT_CONNECTION_FAILURE, instance); } @@ -210,8 +209,5 @@ public class GlobalApp extends Application implements LibFreeRDP.EventListener public void OnDisconnected(int instance) { Log.v("LibFreeRDP", "OnDisconnected"); - - // free session - GlobalApp.freeSession(instance); } } diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/SessionActivity.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/SessionActivity.java index 657678bc7..3d1c5adc1 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/SessionActivity.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/SessionActivity.java @@ -256,7 +256,6 @@ public class SessionActivity extends Activity if (!connectCancelledByUser) uiHandler.sendMessage(Message.obtain(null, UIHandler.DISPLAY_TOAST, getResources().getText(R.string.error_connection_failure))); - session = null; closeSessionActivity(RESULT_CANCELED); } @@ -271,7 +270,6 @@ public class SessionActivity extends Activity } session.setUIEventListener(null); - session = null; closeSessionActivity(RESULT_OK); } } @@ -518,9 +516,13 @@ public class SessionActivity extends Activity protected void onDestroy() { super.onDestroy(); Log.v(TAG, "Session.onDestroy"); - + // unregister freerdp events broadcast receiver unregisterReceiver(libFreeRDPBroadcastReceiver); + + // free session + GlobalApp.freeSession(session.getInstance()); + session = null; } @Override