weimingtom / rokon

Automatically exported from code.google.com/p/rokon
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

onLoadComplete execute when exit game #143

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
press back button to exit game

What is the expected output?
exit normally

What do you see instead?
after exit, will pop up an error message caused by null pointer exception

What version of Rokon are you using?
latest revision 365

On which version of Android are you experiencing this?
1.5

Please provide any additional information below.
I add debug.print("onLoadComplete") in onLoadComplete function, when exit game, 
this function will be called again! revision 364 doesn't have this bug.

Original issue reported on code.google.com by rayjun...@gmail.com on 18 Aug 2010 at 2:39

GoogleCodeExporter commented 9 years ago
This isn't a bug.

This is a WIP, you MUST now override the back button and call finish yourself, 
then its' fine. This is part of the fix for the onDetroy bug.

Original comment by rtaylor205@gmail.com on 18 Aug 2010 at 7:33

GoogleCodeExporter commented 9 years ago
it still have problem when exit game calling onLoadComplete again!
This is my code to call finish myself:
public boolean onKeyDown(int keyCode, KeyEvent event)
    {
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)
        {
            finish();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

so now I have to put these code:
Textures.load();
setScene(new SplashScene());

in onCreate function to avoid exception

Original comment by rayjun...@gmail.com on 19 Aug 2010 at 1:18

GoogleCodeExporter commented 9 years ago
I think the issue is that during RokonActivity.dispose() engineLoaded is being 
set to false, but the RokonRenderer.onDrawFrame is being called over and over 
by renderer, so it sets engineLoaded and calls the onLoadComplete and starts a 
new Thread.  Only since it is in the process of finishing, everything is 
destroyed.

I'm not sure if this is the "right" fix, but I did this:

Index: RokonRenderer.java
===================================================================
--- RokonRenderer.java  (revision 365)
+++ RokonRenderer.java  (working copy)
@@ -48,7 +48,11 @@
        GLHelper.setGL(gl);

        Time.update();
-       
+
+        if(!RokonActivity.engineCreated) {
+            return;
+        }
+
        if(!RokonActivity.engineLoaded) {
            RokonActivity.engineLoaded = true;
            System.gc();

Original comment by jkoel...@gmail.com on 30 Aug 2010 at 2:20