File tree Expand file tree Collapse file tree 1 file changed +14
-31
lines changed Expand file tree Collapse file tree 1 file changed +14
-31
lines changed Original file line number Diff line number Diff line change @@ -215,6 +215,8 @@ private static void InitClassBase(Type type, ClassBase impl)
215
215
var item = ( ManagedType ) iter . Value ;
216
216
var name = ( string ) iter . Key ;
217
217
Runtime . PyDict_SetItemString ( dict , name , item . pyHandle ) ;
218
+ // Decref the item now that it's been used.
219
+ item . DecrRefCount ( ) ;
218
220
}
219
221
220
222
// If class has constructors, generate an __doc__ attribute.
@@ -461,41 +463,22 @@ private static ClassInfo GetClassInfo(Type type)
461
463
462
464
return ci ;
463
465
}
464
- }
465
-
466
-
467
- internal class ClassInfo : IDisposable
468
- {
469
- public Indexer indexer ;
470
- public Hashtable members ;
471
-
472
- internal ClassInfo ( )
473
- {
474
- members = new Hashtable ( ) ;
475
- indexer = null ;
476
- }
477
-
478
- ~ ClassInfo ( )
466
+
467
+ /// <summary>
468
+ /// This class owns references to PyObjects in the `members` member.
469
+ /// The caller has responsibility to DECREF them.
470
+ /// </summary>
471
+ private class ClassInfo
479
472
{
480
- Dispose ( ) ;
481
- }
482
-
483
- private bool disposed = false ;
473
+ public Indexer indexer ;
474
+ public Hashtable members ;
484
475
485
- public void Dispose ( )
486
- {
487
- if ( ! disposed )
476
+ internal ClassInfo ( )
488
477
{
489
- disposed = true ;
490
- foreach ( DictionaryEntry member in members )
491
- {
492
- var item = ( ManagedType ) member . Value ;
493
- if ( item != null )
494
- {
495
- item . DecrRefCount ( ) ;
496
- }
497
- }
478
+ members = new Hashtable ( ) ;
479
+ indexer = null ;
498
480
}
499
481
}
500
482
}
483
+
501
484
}
You can’t perform that action at this time.
0 commit comments