I got this odd problem when persisting From instances.
When I do the following:
-- maSession := MagmaSession openLocal: '/home/hilaire/MagmaDB'. maSession connectAs: 'hilaire'
maSession commit: [maSession root at: 'test' put: ((WatchMorph new imageFormDepth: 16)]. maSession disconnect;closeRepository --
Then when I quit Squeak (without saving the image) and start it again and do:
-- maSession := MagmaSession openLocal: '/home/hilaire/MagmaDB'. maSession connectAs: 'hilaire' (maSession root at: 'test') display --
I got an error message from the BitBlt>>copyBits:
Bad BitBlt arg (Fraction?); proceed to convert.
After proceeding, it is display fine.
Inspecting the Form does not reveal anything special.
Any tips about this problem?
Hilaire
Hi Hilaire, thanks for the great question. When this code
(maSession root at: 'test')
runs it returns a Dictionary composed as follows:
'test' -> aForm
and aForm is composed as:
aForm bits = ***aMaMutatingProxy*** width = someInteger height = someInteger depth = someInteger offset = aPoint
aForm is then sent:
#display
which ends up comparing the 'bits' with an inlined message, or using the 'bits' as an argument to a primitive (I dind't take the trouble to discover which).
So a ReadStrategy is needed to materialize Forms / BitMaps:
maSession := MagmaSession openLocal: '/home/hilaire/MagmaDB'. maSession connectAs: 'hilaire'.
"*** add this code ***" maSession readStrategy: ((MaReadStrategy minimumDepth: 1) onAny: Form readToDepth: 999 ; yourself).
(maSession root at: 'test') display
ReadStrategy's are critical to using Magma. They are used for 1) optimizing performance, 2) ensuring any MagmaProxy is never sent an inlined message (like ==) or 3) ensuring any MagmaProxy is never an argument to a primitive.
So why was the 'offset' a Point instead of a Proxy? Because, if you look at MaReadStrategy>>#initializeDefaultSpecifications, you will see that Point, among several other classes, is part of the default ReadStrategy to read 99 levels deep.
For the next release I will add BitMap and Form to this list as well so you don't have to put them into your own ReadStrategy in the future.
Thanks for finding this..!
- Chris
--- Hilaire Fernandes hilaire2006@laposte.net wrote:
I got this odd problem when persisting From instances.
When I do the following:
-- maSession := MagmaSession openLocal: '/home/hilaire/MagmaDB'. maSession connectAs: 'hilaire'
maSession commit: [maSession root at: 'test' put: ((WatchMorph new imageFormDepth: 16)]. maSession disconnect;closeRepository --
Then when I quit Squeak (without saving the image) and start it again and do:
-- maSession := MagmaSession openLocal: '/home/hilaire/MagmaDB'. maSession connectAs: 'hilaire' (maSession root at: 'test') display --
I got an error message from the BitBlt>>copyBits:
Bad BitBlt arg (Fraction?); proceed to convert.
After proceeding, it is display fine.
Inspecting the Form does not reveal anything special.
Any tips about this problem?
Hilaire
Magma mailing list Magma@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/magma
Wow, impressive explaination!
As a trade-off, until you explain there, I saved the picture of the morph as a PNG image in a Stream as:
morph := WatchMorph new. myStream := RWBinaryOrTextStream with: (ByteArray new: 20). PNGReadWriter putForm: morph imageForm onStream: myStream. maSession commit: [maSession root at: 'image' put: myStream]
then
(PNGReadWriter formFromStream: (maSession root at: 'image')) display
worked as a charm.
I have one question regarding your use of the readStrategy, why do you use a readToDepth of 999? As I understand the readStrategy I believe a value of 1 will just be enought.
Hilaire
Chris Muller a écrit :
"*** add this code ***" maSession readStrategy: ((MaReadStrategy minimumDepth: 1) onAny: Form readToDepth: 999 ; yourself).
(maSession root at: 'test') display
ReadStrategy's are critical to using Magma. They are used for 1) optimizing performance, 2) ensuring any MagmaProxy is never sent an inlined message (like ==) or 3) ensuring any MagmaProxy is never an argument to a primitive.
So why was the 'offset' a Point instead of a Proxy? Because, if you look at MaReadStrategy>>#initializeDefaultSpecifications, you will see that Point, among several other classes, is part of the default ReadStrategy to read 99 levels deep.
For the next release I will add BitMap and Form to this list as well so you don't have to put them into your own ReadStrategy in the future.
Thanks for finding this..!
- Chris
magma@lists.squeakfoundation.org