]> rtime.felk.cvut.cz Git - orte.git/commitdiff
shape_android: fix freezes on app restart
authorMartin Vajnar <martin.vajnar@gmail.com>
Sat, 2 May 2015 11:46:43 +0000 (13:46 +0200)
committerMartin Vajnar <martin.vajnar@gmail.com>
Fri, 22 May 2015 11:29:07 +0000 (13:29 +0200)
When application was exited through 'back' button domain associated with
the running instance was destroyed, however the publishers and subscribers
registered within that domain were left intact.

This caused 'Application Not Responding' to be thrown when user wants to
start the application again, because it tries to use handles associated
with the now defunct publishers/subscribers.

In order to prevent this, we destroy Publisher and Subscriber objects upon
invocation of onDestroy() callback method.

orte/contrib/shape_android/src/org/ocera/orte/shape_android/PublisherActivity.java
orte/contrib/shape_android/src/org/ocera/orte/shape_android/PublisherShape.java
orte/contrib/shape_android/src/org/ocera/orte/shape_android/SubscriberElement.java

index 11e8bab8335a6e12e232457b91b002a31bb08aeb..05d76ff5c8d3fd8da905b903ee42cf58dcf49be3 100644 (file)
@@ -171,7 +171,13 @@ public class PublisherActivity extends Activity {
        public void onDestroy()
        {
                super.onDestroy();
-               
+
+               for (PublisherShape shape : publisherView.shapes)
+                       shape.killMe();
+
+               for (SubscriberElement element : subscriberView.elements)
+                       element.killMe();
+
                if (appDomain != null) {
                        appDomain.destroy();
                        appDomain = null;
index daf55adb4b988d6e8def4c49403eb16d8d08d06e..212be3f016208255eb5f19ce51e4d76cecb9e81e 100644 (file)
@@ -312,7 +312,10 @@ public class PublisherShape extends ShapeDrawable
         */
        public void killMe()
        {
-               this.publication.destroy();
+               if (this.publication != null) {
+                       this.publication.destroy();
+                       this.publication = null;
+               }
        }
        
        /**
index a16326ae5bd90a793588c7868a4d3eeec7429a14..6b74f63fc900cd2f72437e95f0ff5dca108fdd40 100644 (file)
@@ -243,4 +243,15 @@ public class SubscriberElement extends SubscriptionCallback
                this.setShape();
        }
 
+        /**
+         * When subscriber is removed, destroy subscription.
+         * 
+         * @since 1.0
+         */
+       public void killMe() {
+               if (this.subscription != null) {
+                       this.subscription.destroy();
+                       this.subscription = null;
+               }
+       }
 }