Browse Source

* pas2jni: Fixed memory leaks when using inherited TP-style objects.

git-svn-id: trunk@34842 -
yury 8 years ago
parent
commit
8e8521c43e
1 changed files with 5 additions and 1 deletions
  1. 5 1
      utils/pas2jni/writer.pas

+ 5 - 1
utils/pas2jni/writer.pas

@@ -676,7 +676,11 @@ begin
     ctObject, ctRecord:
     ctObject, ctRecord:
       begin
       begin
         Fjs.WriteLn('private native void __Destroy(long pasobj);');
         Fjs.WriteLn('private native void __Destroy(long pasobj);');
-        Fjs.WriteLn(Format('protected %s(long objptr, boolean cleanup) { __Init(objptr, cleanup); }', [d.Name]));
+        if d.AncestorClass = nil then
+          s:='__Init'
+        else
+          s:='super';
+        Fjs.WriteLn(Format('protected %s(long objptr, boolean cleanup) { %s(objptr, cleanup); }', [d.Name, s]));
         Fjs.WriteLn(Format('public %s() { __Init(0, true); }', [d.Name]));
         Fjs.WriteLn(Format('public %s() { __Init(0, true); }', [d.Name]));
         Fjs.WriteLn(Format('public void __Release() { __Destroy(_pasobj); _pasobj=0; }', [d.Name]));
         Fjs.WriteLn(Format('public void __Release() { __Destroy(_pasobj); _pasobj=0; }', [d.Name]));
         Fjs.WriteLn(Format('public int __Size() { return __Size(%d); }', [FRecords.Add(d)]));
         Fjs.WriteLn(Format('public int __Size() { return __Size(%d); }', [FRecords.Add(d)]));