foxygit / fake-08-xbox360 Log in
commit f8eabd12e20a69d1de4147731b27803a547a6712
Author:     Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Sun Jan 28 16:32:40 2024 -0700
Commit:     Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Sun Jan 28 16:32:40 2024 -0700

    don't close lua state on cart close
---
 source/vm.cpp | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/source/vm.cpp b/source/vm.cpp
index 13081e6..6df0c41 100644
--- a/source/vm.cpp
+++ b/source/vm.cpp
@@ -298,15 +298,22 @@ Vm::Vm(
 Vm::~Vm(){
     CloseCart();

-    Logger_Write("printing stack before close\n");
+    if (_luaState != nullptr) {
+        Logger_Write("printing stack before close\n");
+        printLuaStack(_luaState);

-    printLuaStack(_luaState);
+        printLuaStack(_luaState);

-    Logger_Write("closing lua state\n");
+        Logger_Write("closing lua state\n");

-    lua_close(_luaState);
-    _luaState = nullptr;
-    Logger_Write("closed lua state\n");
+        lua_close(_luaState);
+        _luaState = nullptr;
+        Logger_Write("closed lua state\n");
+    }
+    else {
+        Logger_Write("lua state was null\n");
+    }
+

     if (_cleanupDeps){
         if (_input != nullptr) {
@@ -668,11 +675,11 @@ void Vm::CloseCart() {
         _loadedCart = nullptr;
     }

-    if (_luaState) {
-        Logger_Write("closing lua state\n");
-        lua_close(_luaState);
-        _luaState = nullptr;
-    }
+    // if (_luaState) {
+    //     Logger_Write("closing lua state\n");
+    //     lua_close(_luaState);
+    //     _luaState = nullptr;
+    // }

     Logger_Write("writing cart data\n");
     if (_cartdataKey.length() > 0) {