Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9caef12

Browse files
author
David Lassonde
committed
wip
1 parent 13f8b53 commit 9caef12

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

src/runtime/pythonengine.cs

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
@@ -223,6 +223,15 @@ public static void Initialize(IEnumerable<string> args, bool setSysArgv = true)
223223

224224
// Make sure we clean up properly on app domain unload.
225225
AppDomain.CurrentDomain.DomainUnload += OnDomainUnload;
226+
//////////////////dltrace/////////////////////
227+
/* Exec(@"
228+
import UnityEngine
229+
import threading
230+
UnityEngine.Debug.Log('>>>>>>>>> Done with PythonEngine.Initialized threading.current_thread() = %s'%threading.current_thread())
231+
");
232+
*/
233+
//////////////////dltrace/////////////////////
234+
226235
}
227236
}
228237

@@ -302,6 +311,62 @@ public static void Shutdown()
302311
{
303312
if (initialized)
304313
{
314+
//////////////////dltrace/////////////////////
315+
/* Exec(@"
316+
import UnityEngine
317+
import threading
318+
UnityEngine.Debug.Log('>>>>>>>>> In PythonEngine.Shutdown() threading.current_thread() = %s'%threading.current_thread())
319+
");
320+
*/
321+
//////////////////dltrace/////////////////////
322+
323+
//////////////////dltrace/////////////////////
324+
/* Exec(@"
325+
import UnityEngine
326+
327+
import sgtk
328+
UnityEngine.Debug.Log('>>>>>>>>> Destroying the engine')
329+
sgtk.platform.current_engine().destroy()
330+
UnityEngine.Debug.Log('>>>>>>>>> Engine destroyed')
331+
332+
from sgtk.platform.qt import QtGui
333+
theApp = QtGui.QApplication.instance()
334+
335+
UnityEngine.Debug.Log('>>>>>>>>> processing events')
336+
theApp.processEvents()
337+
338+
if theApp:
339+
for child in theApp.children():
340+
UnityEngine.Debug.Log('>>>>>>>>> Scheduling for deletion: %s'%child)
341+
child.deleteLater()
342+
343+
UnityEngine.Debug.Log('>>>>>>>>> processing events')
344+
theApp.processEvents()
345+
346+
UnityEngine.Debug.Log('>>>>>>>>> calling quit on QApplication')
347+
retVal = theApp.quit()
348+
UnityEngine.Debug.Log('>>>>>>>>> done. retVal = %s'%retVal)
349+
350+
UnityEngine.Debug.Log('>>>>>>>>> processing events')
351+
theApp.processEvents()
352+
353+
#import sys
354+
#UnityEngine.Debug.Log('>>>>>>>>> calling sys.exit()')
355+
#sys.exit()
356+
#UnityEngine.Debug.Log('>>>>>>>>> done calling sys.exit()')
357+
358+
");
359+
*/
360+
//////////////////dltrace/////////////////////
361+
362+
//////////////////dltrace/////////////////////
363+
/* Exec(@"
364+
import UnityEngine
365+
UnityEngine.Debug.Log('>>>>>>>>> Back from python cleanup')
366+
");
367+
*/
368+
//////////////////dltrace/////////////////////
369+
305370
PyScopeManager.Global.Clear();
306371
Marshal.FreeHGlobal(_pythonHome);
307372
_pythonHome = IntPtr.Zero;
@@ -312,6 +377,7 @@ public static void Shutdown()
312377

313378
Runtime.Shutdown();
314379

380+
315381
AppDomain.CurrentDomain.DomainUnload -= OnDomainUnload;
316382
initialized = false;
317383
}

0 commit comments

Comments
 (0)