{"action":"created","issue":{"url":"https://api.github.com/repos/GoranM/bdx/issues/442","labels_url":"https://api.github.com/repos/GoranM/bdx/issues/442/labels{/name}","comments_url":"https://api.github.com/repos/GoranM/bdx/issues/442/comments","events_url":"https://api.github.com/repos/GoranM/bdx/issues/442/events","html_url":"https://github.com/GoranM/bdx/issues/442","id":108868091,"number":442,"title":"Bug: Scene Restart Doesn't End GameObjects","user":{"login":"SolarLune","id":4733521,"avatar_url":"https://avatars.githubusercontent.com/u/4733521?v=3","gravatar_id":"","url":"https://api.github.com/users/SolarLune","html_url":"https://github.com/SolarLune","followers_url":"https://api.github.com/users/SolarLune/followers","following_url":"https://api.github.com/users/SolarLune/following{/other_user}","gists_url":"https://api.github.com/users/SolarLune/gists{/gist_id}","starred_url":"https://api.github.com/users/SolarLune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SolarLune/subscriptions","organizations_url":"https://api.github.com/users/SolarLune/orgs","repos_url":"https://api.github.com/users/SolarLune/repos","events_url":"https://api.github.com/users/SolarLune/events{/privacy}","received_events_url":"https://api.github.com/users/SolarLune/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-29T13:23:00Z","updated_at":"2015-09-30T04:17:23Z","closed_at":null,"body":"Hey, there. So basically, if you restart a game scene, the game objects within aren't ended, and so their references never turn invalid.\r\n\r\nI'm looking into fixing this now, but it seems like it might not be possible under our current code-base. I tried just adding a loop to end all objects in the scene, but I can't because we can't simply dispose of models or textures twice, and I don't see a way to check to see if a model's been disposed already. This is the error I get:\r\n\r\n```\r\nException in thread \"LWJGL Application\" java.lang.IllegalArgumentException: buffer not allocated with newUnsafeByteBuffer or already disposed\r\n        at com.badlogic.gdx.utils.BufferUtils.disposeUnsafeByteBuffer(BufferUtils.java:507)\r\n        at com.badlogic.gdx.graphics.glutils.VertexBufferObject.dispose(VertexBufferObject.java:219)\r\n        at com.badlogic.gdx.graphics.Mesh.dispose(Mesh.java:581)\r\n        at com.badlogic.gdx.graphics.g3d.Model.dispose(Model.java:350)\r\n        at com.nilunder.bdx.GameObject.endNoChildren(GameObject.java:556)\r\n        at com.nilunder.bdx.GameObject.end(GameObject.java:548)\r\n        at com.nilunder.bdx.Scene.runObjectLogic(Scene.java:666)\r\n        at com.nilunder.bdx.Scene.update(Scene.java:718)\r\n        at com.nilunder.bdx.Bdx.main(Bdx.java:178)\r\n        at com.solarlune.airgrift.BdxApp.render(BdxApp.java:29)\r\n        at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:214)\r\n        at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)\r\n```\r\n\r\nI guess an alternative would be to simply end the current scene and start a new duplicate scene at the same position when scene.restart() is called? References to the scene would be wrecked, of course, which is kind of a similar problem as what it is currently.\r\n\r\nEDIT: Another alternative would be to make a \"secret\" undocumented function that simply allows BDX to force the validity on GameObjects."},"comment":{"url":"https://api.github.com/repos/GoranM/bdx/issues/comments/144277015","html_url":"https://github.com/GoranM/bdx/issues/442#issuecomment-144277015","issue_url":"https://api.github.com/repos/GoranM/bdx/issues/442","id":144277015,"user":{"login":"SolarLune","id":4733521,"avatar_url":"https://avatars.githubusercontent.com/u/4733521?v=3","gravatar_id":"","url":"https://api.github.com/users/SolarLune","html_url":"https://github.com/SolarLune","followers_url":"https://api.github.com/users/SolarLune/followers","following_url":"https://api.github.com/users/SolarLune/following{/other_user}","gists_url":"https://api.github.com/users/SolarLune/gists{/gist_id}","starred_url":"https://api.github.com/users/SolarLune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SolarLune/subscriptions","organizations_url":"https://api.github.com/users/SolarLune/orgs","repos_url":"https://api.github.com/users/SolarLune/repos","events_url":"https://api.github.com/users/SolarLune/events{/privacy}","received_events_url":"https://api.github.com/users/SolarLune/received_events","type":"User","site_admin":false},"created_at":"2015-09-30T04:17:23Z","updated_at":"2015-09-30T04:17:23Z","body":"PR submitted. Worked first try - thanks for the help!"}}