| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Repo", "Repo", "{441A0123-F | |||
| 25 | 25 | EndProject | |
| 26 | 26 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CI", "CI", "{D301657F-5EAF-4534-B280-B858D651B2E5}" | |
| 27 | 27 | ProjectSection(SolutionItems) = preProject | |
| 28 | + .github\workflows\ARM.yml = .github\workflows\ARM.yml | ||
| 28 | 29 | .github\workflows\main.yml = .github\workflows\main.yml | |
| 29 | 30 | .github\workflows\nuget-preview.yml = .github\workflows\nuget-preview.yml | |
| 30 | 31 | EndProjectSection | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,8 +54,9 @@ private static string GetDefaultDllName(Version version) | |||
| 54 | 54 | } | |
| 55 | 55 | ||
| 56 | 56 | private static bool _isInitialized = false; | |
| 57 | - | ||
| 58 | 57 | internal static bool IsInitialized => _isInitialized; | |
| 58 | + private static bool _typesInitialized = false; | ||
| 59 | + internal static bool TypeManagerInitialized => _typesInitialized; | ||
| 59 | 60 | internal static readonly bool Is32Bit = IntPtr.Size == 4; | |
| 60 | 61 | ||
| 61 | 62 | // .NET core: System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows) | |
@@ -151,6 +152,7 @@ internal static void Initialize(bool initSigs = false) | |||
| 151 | 152 | ClassManager.Reset(); | |
| 152 | 153 | ClassDerivedObject.Reset(); | |
| 153 | 154 | TypeManager.Initialize(); | |
| 155 | + _typesInitialized = true; | ||
| 154 | 156 | ||
| 155 | 157 | // Initialize modules that depend on the runtime class. | |
| 156 | 158 | AssemblyManager.Initialize(); | |
@@ -272,6 +274,7 @@ internal static void Shutdown() | |||
| 272 | 274 | NullGCHandles(ExtensionType.loadedExtensions); | |
| 273 | 275 | ClassManager.RemoveClasses(); | |
| 274 | 276 | TypeManager.RemoveTypes(); | |
| 277 | + _typesInitialized = false; | ||
| 275 | 278 | ||
| 276 | 279 | MetaType.Release(); | |
| 277 | 280 | PyCLRMetaType.Dispose(); | |
@@ -291,9 +294,10 @@ internal static void Shutdown() | |||
| 291 | 294 | Finalizer.Shutdown(); | |
| 292 | 295 | InternString.Shutdown(); | |
| 293 | 296 | ||
| 297 | + ResetPyMembers(); | ||
| 298 | + | ||
| 294 | 299 | if (!HostedInPython) | |
| 295 | 300 | { | |
| 296 | - ResetPyMembers(); | ||
| 297 | 301 | GC.Collect(); | |
| 298 | 302 | GC.WaitForPendingFinalizers(); | |
| 299 | 303 | PyGILState_Release(state); | |
@@ -310,7 +314,6 @@ internal static void Shutdown() | |||
| 310 | 314 | } | |
| 311 | 315 | else | |
| 312 | 316 | { | |
| 313 | - ResetPyMembers(); | ||
| 314 | 317 | PyGILState_Release(state); | |
| 315 | 318 | } | |
| 316 | 319 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -832,6 +832,7 @@ public void ResetSlots() | |||
| 832 | 832 | var metatype = Runtime.PyObject_TYPE(Type); | |
| 833 | 833 | ManagedType.TryFreeGCHandle(Type, metatype); | |
| 834 | 834 | } | |
| 835 | + Runtime.PyType_Modified(Type); | ||
| 835 | 836 | } | |
| 836 | 837 | ||
| 837 | 838 | public static IntPtr GetDefaultSlot(int offset) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,10 +59,7 @@ protected override NewReference NewObjectToPython(object obj, BorrowedReference | |||
| 59 | 59 | // Decrement the python object's reference count. | |
| 60 | 60 | // This doesn't actually destroy the object, it just sets the reference to this object | |
| 61 | 61 | // to be a weak reference and it will be destroyed when the C# object is destroyed. | |
| 62 | - if (!self.IsNull()) | ||
| 63 | - { | ||
| 64 | - Runtime.XDecref(self.Steal()); | ||
| 65 | - } | ||
| 62 | + Runtime.XDecref(self.Steal()); | ||
| 66 | 63 | ||
| 67 | 64 | return Converter.ToPython(obj, type.Value); | |
| 68 | 65 | } | |
@@ -942,13 +939,16 @@ internal static void Finalize(IntPtr derived) | |||
| 942 | 939 | ||
| 943 | 940 | var type = Runtime.PyObject_TYPE(@ref.Borrow()); | |
| 944 | 941 | ||
| 945 | - // rare case when it's needed | ||
| 946 | - // matches correspdonging PyObject_GC_UnTrack | ||
| 947 | - // in ClassDerivedObject.tp_dealloc | ||
| 948 | - Runtime.PyObject_GC_Del(@ref.Steal()); | ||
| 942 | + if (!Runtime.HostedInPython || Runtime.TypeManagerInitialized) | ||
| 943 | + { | ||
| 944 | + // rare case when it's needed | ||
| 945 | + // matches correspdonging PyObject_GC_UnTrack | ||
| 946 | + // in ClassDerivedObject.tp_dealloc | ||
| 947 | + Runtime.PyObject_GC_Del(@ref.Steal()); | ||
| 949 | 948 | ||
| 950 | - // must decref our type | ||
| 951 | - Runtime.XDecref(StolenReference.DangerousFromPointer(type.DangerousGetAddress())); | ||
| 949 | + // must decref our type | ||
| 950 | + Runtime.XDecref(StolenReference.DangerousFromPointer(type.DangerousGetAddress())); | ||
| 951 | + } | ||
| 952 | 952 | } | |
| 953 | 953 | ||
| 954 | 954 | internal static FieldInfo? GetPyObjField(Type type) => type.GetField(PyObjName, PyObjFlags); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments