Browse Source

Fix for GC'd delegates

Josh Engebretson 9 years ago
parent
commit
cdd61110fe

+ 1 - 1
Build/Scripts/BuildCommon.js

@@ -89,7 +89,7 @@ namespace('build', function() {
       // Compile AtomicNET assemblies
       // Compile AtomicNET assemblies
       var cmds = [];
       var cmds = [];
 
 
-      cmds.push(host.atomicTool + " net compile " + atomicRoot + "Script/AtomicNET/AtomicNETProject.json " + platform + " " + configuration);
+      cmds.push(host.atomicTool + " net compile " + atomicRoot + "Script/AtomicNET/AtomicNETProject.json -platform " + platform + " -config " + configuration);
 
 
       jake.exec(cmds, function() {
       jake.exec(cmds, function() {
 
 

+ 5 - 1
Script/AtomicNET/AtomicNET/Core/AtomicNET.cs

@@ -46,6 +46,10 @@ namespace AtomicEngine
         [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
         [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
         private static extern uint csi_Atomic_AtomicNET_StringToStringHash(string name);
         private static extern uint csi_Atomic_AtomicNET_StringToStringHash(string name);
 
 
+        // static members so they don't get GC'd
+        private static EventDispatchDelegate eventDispatchDelegate = NativeCore.EventDispatch;
+        private static UpdateDispatchDelegate updateDispatchDelegate = NativeCore.UpdateDispatch;
+
         public static void Initialize()
         public static void Initialize()
         {
         {
             // Atomic Modules
             // Atomic Modules
@@ -77,7 +81,7 @@ namespace AtomicEngine
 
 
             PlayerModule.Initialize();
             PlayerModule.Initialize();
 
 
-            IntPtr coreptr = csi_Atomic_NETCore_Initialize(NativeCore.EventDispatch, NativeCore.UpdateDispatch);
+            IntPtr coreptr = csi_Atomic_NETCore_Initialize(eventDispatchDelegate, updateDispatchDelegate);
 
 
             NETCore core = (coreptr == IntPtr.Zero ? null : NativeCore.WrapNative<NETCore>(coreptr));
             NETCore core = (coreptr == IntPtr.Zero ? null : NativeCore.WrapNative<NETCore>(coreptr));
 
 

+ 1 - 1
Source/AtomicTool/CMakeLists.txt

@@ -51,5 +51,5 @@ add_custom_target ( GenerateScriptBindings
 
 
 add_custom_target ( GenerateAtomicNET
 add_custom_target ( GenerateAtomicNET
                     WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
                     WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
-                    COMMAND ${ATOMIC_NODE_JAKE};build:genAtomicNET[${JAVASCRIPT_BINDINGS_PLATFORM},$<$<CONFIG:debug>:"Debug">$<$<CONFIG:release>:"Release">];--trace
+                    COMMAND ${ATOMIC_NODE_JAKE};build:genAtomicNET[desktop,$<$<CONFIG:debug>:"Debug">$<$<CONFIG:release>:"Release">];--trace
                     DEPENDS AtomicTool )
                     DEPENDS AtomicTool )