diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index be5d095..44047cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: # Default value means that a failure in one OS cancels all fail-fast: false matrix: - smalltalk: [ Pharo64-11 ] + smalltalk: [ Pharo64-11, Pharo64-12 ] os: [ ubuntu-latest, macos-latest, windows-latest ] ston: [ .ci.ston ] runs-on: ${{ matrix.os }} diff --git a/src/Alexandrie-Base/AeTExternalFree.trait.st b/src/Alexandrie-Base/AeTExternalFree.trait.st index 2815965..37df62d 100644 --- a/src/Alexandrie-Base/AeTExternalFree.trait.st +++ b/src/Alexandrie-Base/AeTExternalFree.trait.st @@ -13,23 +13,13 @@ AeTExternalFree classSide >> externallyFree: aHandle [ ] { #category : #finalization } -AeTExternalFree classSide >> finalizeResourceData: anObject [ +AeTExternalFree classSide >> finalizeResourceData: aHandle [ - | aHandle | - aHandle := self resourceDataFrom: anObject. aHandle isNull ifTrue: [ ^ self ]. self externallyFree: aHandle. aHandle beNull ] -{ #category : #finalization } -AeTExternalFree classSide >> resourceDataFrom: anObject [ - "Answer the handle from the resource data received as parameter. - This is the inverse of the `resourceData` as implemented in instance-side." - - ^ anObject -] - { #category : #finalization } AeTExternalFree >> autoRelease [ "Add to finalization system so GC frees me when there are no more references. @@ -47,7 +37,8 @@ AeTExternalFree >> externallyFree [ { #category : #finalization } AeTExternalFree >> resourceData [ - "Answer an object that doesn't point to self and that is used in `resourceDataFrom:` to obtain the handle at freeing time." + "Answer an object to be received in `finalizeResourceData:` to free external resources. + Such object will be stored in a finalization registry, so shouldn't point directly or indirectly to myself." ^ self getHandle ] diff --git a/src/Alexandrie-FreeType/AeFTFace.class.st b/src/Alexandrie-FreeType/AeFTFace.class.st index eaa8e0b..6f1dde1 100644 --- a/src/Alexandrie-FreeType/AeFTFace.class.st +++ b/src/Alexandrie-FreeType/AeFTFace.class.st @@ -58,6 +58,19 @@ AeFTFace class >> fieldsDesc [ "... we ignore remaining fields" ] +{ #category : #finalization } +AeFTFace class >> finalizeResourceData: anArray [ + "Free a face, with an exception: If library was already freed, then all faces were already freed." + + | libraryHandle aHandle | + aHandle := anArray first. + libraryHandle := anArray second. + libraryHandle isNull ifFalse: [ + aHandle isNull ifTrue: [ ^ self ]. + self externallyFree: aHandle ]. + aHandle beNull +] + { #category : #accessing } AeFTFace >> charHeight: aNumber [ "Request nominal height, taking resolution of 72 dpi." @@ -253,6 +266,13 @@ AeFTFace >> printOn: aStream [ self printFaceFlagsOn: aStream ] +{ #category : #finalization } +AeFTFace >> resourceData [ + "Answer an object that doesn't point to self and that is used in `resourceDataFrom:` to obtain the handle at freeing time." + + ^ { self getHandle. library getHandle } +] + { #category : #'accessing - structure variables' } AeFTFace >> styleFlags [ "This method was automatically generated" diff --git a/src/Alexandrie-FreeType/AeFTLibrary.class.st b/src/Alexandrie-FreeType/AeFTLibrary.class.st index 78e7889..3e15c8f 100644 --- a/src/Alexandrie-FreeType/AeFTLibrary.class.st +++ b/src/Alexandrie-FreeType/AeFTLibrary.class.st @@ -119,6 +119,7 @@ AeFTLibrary >> newFaceFromBytes: aByteArray index: aZeroBasedIndex [ AeFreeTypeError signalForCode: returnCode ]. ^ (AeFTFace fromHandle: aPointer) + library: self; autoRelease; yourself ] @@ -138,6 +139,7 @@ AeFTLibrary >> newFaceFromFile: aFileReference index: aZeroBasedIndex [ AeFreeTypeError signalForCode: returnCode ]. ^ (AeFTFace fromHandle: aPointer) + library: self; autoRelease; yourself ]